PrefectHQ
prefect
BlogDocsChangelog

Fix multiprocessing deadlock after using prefect_test_harness on Linux

#19116
Comparing
fix/multiprocessing-after-test-harness
(
70f476f
) with
main
(
4cf3f90
)
CodSpeed Performance Gauge
0%
Untouched
2
Ignored
6

Benchmarks

Passed

bench_task_decorator
benches/bench_tasks.py
CodSpeed Performance Gauge
0%
460.7 µs459.8 µs
bench_import_prefect_flow
benches/bench_import.py
CodSpeed Performance Gauge
0%
1.4 s1.4 s

Ignored

bench_import_prefect
benches/bench_import.py
Ignored
CodSpeed Performance Gauge
0%
2.6 ms2.6 ms
bench_task_call
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
-3%
157.5 ms162.4 ms
bench_task_submit
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
-20%
4.6 ms5.8 ms
bench_flow_decorator
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
+11%
4.2 ms3.7 ms
bench_flow_call[options1]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
0%
106 ms106.1 ms
bench_flow_call[options0]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
+2%
169.7 ms166.4 ms

Commits

Click on a commit to change the comparison range
Base
main
4cf3f90
+0.05%
Fix type errors by making fork reset methods public Remove underscore prefix from reset_for_fork methods to avoid reportPrivateUsage errors when calling from module-level fork handlers. Verified with: uv run pyright -p pyrightconfig-ci.json --level error
6ac8315
2 days ago
by zzstoatzz
-0.32%
Replace smoke tests with proper regression test for multiprocessing deadlock Moved the test from internal concurrency tests to testing utilities where it belongs, and replaced the useless smoke tests with a real test that reproduces the actual issue: using multiprocessing.Process() after prefect_test_harness(). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
4a907e5
2 days ago
by zzstoatzz
+0.22%
Use os._exit(0) in multiprocessing worker to bypass Python cleanup On Linux with fork(), the child process inherits Prefect's logging and event state. When the worker function returns normally, Python's cleanup tries to flush logs/close connections, which can fail since those resources are in an inconsistent state after fork. Using os._exit(0) bypasses cleanup entirely. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
48cf4d9
2 days ago
by zzstoatzz
+0.16%
Use os._exit(0) to avoid Python cleanup in forked child process On Linux with fork(), the child process inherits Prefect's logging/event state. Normal exit (return or sys.exit) triggers Python cleanup that fails with this inherited state, causing exitcode=1. os._exit() bypasses cleanup and is documented for use "in the child process after os.fork()". Despite the underscore prefix, this is the intended API for this scenario. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
70f476f
2 days ago
by zzstoatzz
© 2025 CodSpeed Technology
Home Terms Privacy Docs