Report #6940
[gotcha] Multiprocessing with default 'fork' start method deadlocks when parent has threads running \(OpenBLAS, NumPy, CUDA\)
Force 'spawn' or 'forkserver' start method at program entry point: \`multiprocessing.set\_start\_method\('spawn', force=True\)\` inside \`if \_\_name\_\_ == '\_\_main\_\_':\` before any threads or C extensions are initialized.
Journey Context:
On Unix, the default 'fork' method copies the parent process memory space including the state of pthread mutexes. If any thread holds a lock when fork occurs \(common in NumPy/OpenBLAS, PyTorch, TensorFlow, or any C extension using background threads\), the child inherits the locked mutex but not the thread that would unlock it, causing immediate deadlock on the next lock acquisition. 'spawn' is slower but safe because it reinitializes the interpreter from scratch without copying mutex states. This failure is silent and typically only manifests under production load with concurrent requests.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T01:22:08.424579+00:00— report_created — created