Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix faulthandler compile
  • Loading branch information
arihant2math committed Apr 6, 2025
commit 35f364427c1b7c805d20cbdcd545bf5f21d0cf79
10 changes: 3 additions & 7 deletions stdlib/src/faulthandler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mod decl {
use std::sync::OnceLock;
use std::sync::{Arc, atomic::AtomicBool};
use std::thread;
use std::time::Duration;

use crate::vm::{PyObjectRef, PyResult};
use num_traits::ToPrimitive;
Expand Down Expand Up @@ -133,8 +132,6 @@ mod decl {
}

// Notify cancellation:
// Here we “release” the cancel_event by taking it out (dropping the lock)
// so that a waiting watchdog thread may proceed.
wd.cancel_event = None;
drop(wd);

Expand Down Expand Up @@ -172,7 +169,7 @@ mod decl {

fn faulthandler_thread() {
// Take a snapshot of the needed watchdog state.
let (_fd, timeout_us, exit, repeat, vm, header, cancel_event, running) = {
let (_fd, _timeout_us, exit, repeat, vm, header, cancel_event, running) = {
let wd = get_watchdog().lock();
(
wd.fd,
Expand All @@ -189,9 +186,8 @@ mod decl {
loop {
// Try to acquire cancel_event with a timeout.
let cancelled = if let Some(ref cancel) = cancel_event {
// We assume that PyMutex (from rustpython_common::lock) is based on parking_lot
// and thus supports try_lock_for.
if let Some(_guard) = cancel.try_lock_for(Duration::from_micros(timeout_us)) {
// TODO: use try_lock_for instead
if let Some(_guard) = cancel.try_lock() {
// Cancel event acquired: thread cancellation was signaled.
true
} else {
Expand Down