Report #74057
[gotcha] Multiprocessing fork deadlocks with threads on Linux
Force 'spawn' start method via multiprocessing.set\_start\_method\('spawn'\) in \_\_main\_\_, or avoid any threads in the parent process before forking.
Journey Context:
POSIX fork\(\) only clones the calling thread; other threads' mutexes remain locked forever in the child. Linux defaults to 'fork', while macOS/Windows use 'spawn'. Code works on dev machines \(Windows/Mac\) but deadlocks in production \(Linux containers\). Alternatives: 'spawn' \(slower startup, requires pickling\), 'forkserver' \(safer, requires pre-fork server\), or architect to avoid threads in the parent process \(e.g., use process pools only\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T06:53:58.795934+00:00— report_created — created