Python Concurrency with asyncio
Python Concurrency with asyncio, by Matthew Fowler (Manning, 2022, about 376 pages), is a practical guide to writing concurrent Python with the standard library’s asyncio package. Fowler is a software engineer with more than 15 years’ experience in roles from architect to engineering director. The book explains how single-threaded concurrency works and when to use it instead of threads or multiple processes, and how to combine all three.
What it covers
- Getting to know asyncio: concurrency vs. parallelism, the GIL, I/O-bound vs. CPU-bound work, and how an event loop works.
- asyncio basics: coroutines,
async/await, tasks, timeouts and cancellation, and futures. - A first application: a non-blocking socket server built from scratch.
- Concurrent web requests with
aiohttp,gather,as_completedandwait. - Non-blocking database drivers with
asyncpg, connection pools and transactions. - CPU-bound work with
multiprocessingand process pools, including a MapReduce example. - Blocking work with threads: running legacy blocking libraries without stalling the event loop.
- Streams: transports, protocols and building command-line tools.
- Web applications: async web frameworks, ASGI and WebSockets.
- Microservices: the backend-for-frontend pattern, retries and circuit breakers.
- Synchronization: locks, semaphores, events and conditions.
- Asynchronous queues, including priority and LIFO queues.
- Managing subprocesses asynchronously.
- Advanced asyncio: custom event loops, context variables, and how
awaitreally works.
Why it’s worth reading
Async Python now powers much of the modern backend, from FastAPI services to LLM agent frameworks that make many concurrent model and tool calls. The book goes beyond syntax to explain the event loop’s internals, so you can reason about performance and avoid common traps such as blocking the loop.