PrefectHQ
prefect
BlogDocsChangelog

Fix wait() timeout not being respected when using WatcherThreadCancelScope

#20257
Comparing
devin/1768496403-fix-wait-timeout
(
2e0323d
) with
main
(
6e8a148
)
CodSpeed Performance Gauge
0%
Untouched
2
Ignored
6

Benchmarks

Passed

bench_task_decorator
benches/bench_tasks.py
CodSpeed Performance Gauge
0%
552.7 µs550.6 µs
bench_import_prefect_flow
benches/bench_import.py
CodSpeed Performance Gauge
0%
1.4 s1.4 s

Ignored

bench_task_call
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
-6%
23.1 ms24.6 ms
bench_task_submit
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
-42%
91.7 ms157.1 ms
bench_flow_call[options1]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
0%
107.4 ms107.4 ms
bench_flow_call[options0]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
0%
106.1 ms106.5 ms
bench_flow_decorator
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
-6%
4.8 ms5.1 ms
bench_import_prefect
benches/bench_import.py
Ignored
CodSpeed Performance Gauge
0%
1.1 s1.1 s

Commits

Click on a commit to change the comparison range
Base
main
6e8a148
+0.18%
Fix wait() timeout not being respected when using WatcherThreadCancelScope The wait() function's timeout was not being properly enforced when pytest-timeout or other code set a SIGALRM handler, causing cancel_sync_after to fall back to WatcherThreadCancelScope. This scope cannot interrupt blocking system calls like threading.Event.wait(). The fix calculates a deadline at the start and passes the remaining time as a timeout to finished_event.wait(). This ensures the wait returns when the deadline is reached, allowing proper timeout handling. This reduces test runtime from ~120 seconds to ~12 seconds for test_wait_monitors_all_futures_concurrently_with_timeout. Co-Authored-By: alex.s@prefect.io <ajstreed1@gmail.com>
f90077c
14 hours ago
by devin-ai-integration[bot]
0%
Restore timeout_context wrapper as requested by reviewer Co-Authored-By: alex.s@prefect.io <ajstreed1@gmail.com>
2e0323d
13 hours ago
by devin-ai-integration[bot]
© 2026 CodSpeed Technology
Home Terms Privacy Docs