Report #30489
[gotcha] multiprocessing fork start method deadlocks with pre-existing threads holding locks
Force 'spawn' start method via multiprocessing.set\_start\_method\('spawn', force=True\) in \_\_main\_\_; never use default 'fork' if any thread \(including logging, monitoring, or third-party libraries\) was ever started in the parent.
Journey Context:
On Linux/macOS, the default start method is 'fork', which copies the entire memory space including lock states. If any thread \(e.g., a background logger, metrics reporter, or even a library's internal thread pool\) holds a lock at the moment of fork, the child process inherits a locked mutex that will never be released \(since the unlocking thread doesn't exist in the child\), causing immediate deadlock on the first use of that subsystem. The 'spawn' method is slower but safer as it starts a fresh Python interpreter. The footgun is assuming that because your code doesn't explicitly use threads, you're safe; many libraries \(including stdlib logging with QueueHandler\) spawn threads behind the scenes. The fix is to explicitly set start method to 'spawn' at the entry point of your application, accepting the performance penalty for correctness.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:33:45.078715+00:00— report_created — created