A multiprocessing script fails on macOS with `RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.`
IntermediateTroubleshootingConcurrency, async, tests, services & containers
Answer
Likely causes → The spawn start method (default on macOS and Windows) re-imports the main module in each child; without an if __name__ == "__main__": guard, the children try to start pools themselves.
Diagnose → Check for top-level code that creates Pool/ProcessPoolExecutor.
Fix → Move the entry code under if __name__ == "__main__": main().
Prevent → Always guard entry points; avoid side effects at import time.
More on Concurrency, async, tests, services & containers
`RuntimeError: asyncio.run() cannot be called from a running event loop` in a Jupyter notebook or inside an async framework.Intermediate`RuntimeWarning: coroutine 'fetch' was never awaited` and nothing happens.BeginnerAn asyncio health-checker is no faster than a sequential loop.Advanced`Task was destroyed but it is pending!` at shutdown.Advanced`OSError: [Errno 24] Too many open files` from an asyncio scanner with 20,000 targets.IntermediateA `ThreadPoolExecutor` job finishes "successfully" but half the work is missing, with no errors logged.Intermediate