Interview Prep/Python for DevOps/Concurrency: threads, processes & asyncio

How do `multiprocessing` and `ProcessPoolExecutor` differ from threads in practice?

AdvancedConceptConcurrency: threads, processes & asyncio
Answer

Each worker is a separate OS process with its own memory and GIL, so CPU-bound work scales across cores. Costs: start-up time, memory per process, and every argument and result is pickled and sent over a pipe (lambdas, open sockets and boto3 clients cannot be pickled). Start methods: fork (Linux default before 3.14, fast but unsafe with threads), spawn (macOS/Windows default, re-imports your module, which is why the __main__ guard is required), forkserver (Linux default from 3.14).

All Python for DevOps questions Roadmap: Python for automation

More on Concurrency: threads, processes & asyncio