Report #102481
[gotcha] multiprocessing 'fork' copies locks and file descriptors into children, causing deadlocks or corruption
Explicitly use 'spawn' or 'forkserver' via multiprocessing.set\_start\_method\('spawn'\) or multiprocessing.get\_context\('spawn'\), especially on macOS and Linux. Avoid creating threads or acquiring locks before spawning child processes. Never pass a lock created under one start method to a process using another.
Journey Context:
On Linux the default was historically 'fork', which clones the entire process including every lock state and file descriptor. If a lock was held by a thread that does not exist in the child, the child can deadlock on the next acquire. macOS moved to spawn by default because system libraries can spawn threads and crash under fork; Python 3.14 makes forkserver the POSIX default. 'spawn' starts a fresh interpreter \(slower, but safe\); 'forkserver' forks from a clean single-threaded server. The safest cross-platform pattern is to spawn early and keep IPC explicit through Queues/Pipes rather than shared locks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T04:57:02.215284+00:00— report_created — created