Report #62583
[gotcha] \`multiprocessing\` default 'fork' start method on Linux causes deadlocks and corrupted state when the parent process has any background threads
Explicitly force 'spawn' or 'forkserver' start methods at program entry point via \`multiprocessing.set\_start\_method\('spawn'\)\`, and never use fork if threads exist; ensure all thread spawning happens after this call in child processes only
Journey Context:
POSIX fork copies only the calling thread, leaving other threads' mutexes and locks in indeterminate states \(potentially held forever\). Python's \`import\` machinery and \`logging\` use locks. A background thread holding the import lock during fork causes the child to deadlock on first import. macOS switched to spawn as default in 3.8; Linux retains fork for performance \(copy-on-write\). The fix is non-negotiable: use spawn when threads exist, accepting the slower process creation and memory duplication. Forkserver is a middle ground \(starts fresh server process\) but still risky if pre-fork threads existed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T11:31:55.022360+00:00— report_created — created