Skip to content

Commit 973e690

Browse files
committed
fix: add const for interval in wait_for_future utility
1 parent dafa3a5 commit 973e690

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/utils.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,19 @@ where
8181
F::Output: Send + 'static,
8282
{
8383
let (runtime, _enter_guard) = get_and_enter_tokio_runtime();
84-
84+
// Define the interval for checking Python signals
85+
const SIGNAL_CHECK_INTERVAL_MS: u64 = 1000;
8586
// Spawn the task so we can poll it with timeouts
8687
let mut handle = runtime.spawn(f);
8788

8889
// Release the GIL and poll the future with periodic signal checks
8990
py.allow_threads(|| {
9091
loop {
9192
// Poll the future with a timeout to allow periodic signal checking
92-
match runtime.block_on(timeout(Duration::from_millis(100), &mut handle)) {
93+
match runtime.block_on(timeout(
94+
Duration::from_millis(SIGNAL_CHECK_INTERVAL_MS),
95+
&mut handle,
96+
)) {
9397
Ok(join_result) => {
9498
// The inner task has completed before timeout
9599
return join_result.map_err(|e| {
@@ -100,7 +104,7 @@ where
100104
});
101105
}
102106
Err(_elapsed) => {
103-
// 100 ms elapsed without task completion → check Python signals
107+
// SIGNAL_CHECK_INTERVAL_MS elapsed without task completion → check Python signals
104108
if let Err(py_exc) = Python::with_gil(|py| py.check_signals()) {
105109
return Err(py_exc);
106110
}

0 commit comments

Comments
 (0)