Report #17634
[gotcha] Deadlocks using multiprocessing with threads on Linux due to unsafe fork
Force 'spawn' or 'forkserver' start method via \`multiprocessing.set\_start\_method\('spawn'\)\` at program entry point; never use default 'fork' if any thread is running.
Journey Context:
Linux defaults to 'fork' for speed, but POSIX fork in a multi-threaded process clones only the forking thread, leaving locks held by dead threads forever. This manifests as non-deterministic deadlocks in Process/Pool. Developers often blame Python or their code, but it's fundamental POSIX fork safety. Spawn avoids this by starting a fresh interpreter, at the cost of slower startup and needing to reimport modules in the child.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T05:53:51.224911+00:00— report_created — created