Multiprocessing¶
Category: Parallelism · Status: stub · Lessons: chapter 08, Processes (planned)
One line: Using several processes instead of several threads — for isolation, or to get parallelism in a runtime whose threads share one global lock.
Also called: process pool, ProcessPoolExecutor.
How it connects¶
flowchart LR
n_ipc["Inter-process communication"]
n_multiprocessing["Multiprocessing"]
n_process["Process"]
n_multiprocessing -->|uses| n_ipc
n_multiprocessing -->|uses| n_process
classDef center stroke-width:3px
class n_multiprocessing center
classDef outside stroke-dasharray: 4 3
class n_ipc,n_process outside
- Is built on: Inter-process communication, Process
- See also: Global interpreter lock, Process
In each language¶
| Python | multiprocessing ↗ and ProcessPoolExecutor ↗; in 3.14 the default start method on POSIX changed from fork to forkserver, while macOS and Windows use spawn |
Where to read more¶
- In the books: Parallel Loops in Python, Jason Brownlee — ch. 5, 'Parallel Loop with the Process Class'
- In the books: Python Parallel Programming Cookbook, Giancarlo Zaccone — ch. 3, 'Process-based Parallelism'
- In the books: Parallel Programming with Python, Jan Palach — ch. 5, 'Using Multiprocessing and ProcessPoolExecutor'
- In the books: Learn Concurrent Programming with Go, James Cutajar — ch. 2, 'Dealing with threads' → 'Multiprocessing in operating systems'
- In the books: Multi-Threaded Programming in C++, Mark Walmsley — ch. 5, 'Semaphores' → 'The POOL Class'
- In the books: Python Concurrency with asyncio, Matthew Fowler — ch. 1, 'Getting to know asyncio' → 'Understanding processes, threads, multithreading, and multiprocessing'
- Notes: multiprocessing python ↗
- Notes: multi-processing - general - multiprocessing ↗
- Reference: Wikipedia: Multiprocessing ↗