liveBook · Manning

Multiprocessing module

As explained in Python Concurrency with asyncio

The multiprocessing module is Python’s standard-library module for creating and managing processes.

The multiprocessing module creates and manages child processes for concurrent and parallel execution. Each process has its own Python interpreter and global interpreter lock, allowing CPU-bound work to use multiple CPU cores effectively. section 6.0 section 6.1

Create a Process with a target function and argument tuple, call start to begin it, then call join so the parent waits for completion. Unlike threads, processes avoid having one interpreter’s GIL prevent parallel Python bytecode execution. section 6.1 section 1.4.2

Running two CPU-bound functions

A counting function runs in two child processes, one counting to 100,000,000 and the other to 200,000,000. Starting both before joining lets their work overlap; the parent then waits for both and reports total elapsed time.

How Python Concurrency with asyncio covers it

How deep it goes
Builds direct Process examples through target functions, arguments, start, join, and timing before deferring pools and shared-state coordination.
Examples
Demonstrates child-process identifiers and parallel counting functions measured with elapsed-time output.
What it assumes
Assumes basic Python functions and arguments while introducing the distinction between processes, threads, concurrency, and parallelism.
What you can do after
Build it from scratch by creating processes, launching target functions, passing arguments, and waiting for completion.
How it connects
Connects multiprocessing with concurrency, parallelism, the global interpreter lock, multithreading, asyncio, process pools, MapReduce, and locks.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Python Concurrency with asyncio. The section links point to the parts of the book it draws on.