Grokking Concurrency in Python
Learn to choose, write, test and debug concurrent Python on current CPython: threads, processes, asyncio, structured concurrency, cancellation, the free-threaded build and subinterpreters, each measured on one running program.

Course Overview
Python offers several ways to do more than one thing at a time. You can use threads, processes, asyncio, the free-threaded build or subinterpreters. The right choice depends on two things: whether your program mostly waits or mostly computes, and what the GIL allows on the build you run. This course teaches every model on one program, a web crawler and search indexer called Harvest. Harvest starts as a sequential script and grows into a concurrent service. Fetching pages is waiting work and indexing them is computing work, so one program shows where each model helps and where it does not. Along the way you learn thread pools, locks and queues, process start methods, the asyncio event loop, TaskGroup, cancellation, deadlines and backpressure. Each lesson measures what its mechanism does to Harvest. It then shows how that mechanism fails in a running service, the symptom you would see, and the check that confirms the cause. Later chapters cover testing concurrent code, diagnosing problems in production, graceful shutdown and sizing a service for its machine. Each lesson names the machine that produced its output, and every result comes from a real run on Python 3.15.2. The course is for engineers who already know Python and need a program to handle more work at once. It also prepares you to defend those design choices with numbers in a code review or an interview.
What you'll learn in Grokking Concurrency in Python
- Tell IO bound work from CPU bound work, size a worker pool for each, and confirm the choice by measuring
- Find race conditions in threaded code and fix them with locks, a fixed lock order, events and queues
- Choose a process start method, keep pickling costs low, and avoid hangs after fork in worker processes
- Group tasks with TaskGroup so one failure cancels the rest, and handle every error with except*
- Bound concurrency, rate limit requests per site, retry with jitter, and stream data with constant memory use
- Measure the free-threaded build, find its new data races, audit dependencies, and plan a migration
- Force races to happen on demand in tests, test timeouts without waiting, and stress code until rare races appear
- Explain what the GIL protects, when CPython releases it, and why a race can still happen while it is on
- Use thread and process pools, collect results and errors, and shut a pool down without losing work
- Build a small event loop from generators, then use asyncio tasks without losing any of them
- Cancel work, set one deadline across a chain of calls, and write cleanup code that still runs
- Call blocking code from async code, and async code from sync code, without stalling the event loop
- Run code in subinterpreters and choose between asyncio, threads, processes and interpreters by measurement
- Diagnose a blocked event loop, a stuck task, a deadlock, a leak and GIL contention in a running service
Course Content
Executors and Futures
Structured Concurrency
Cancellation and Timeouts
Subinterpreters and Choosing a Model
Testing Concurrent Code
Diagnosing Problems in Production
Production Patterns
Capstone: Harvest End to End
Practice Problems
What people say about our courses






About the Author

Arslan Ahmad
Industry Expertise & Leadership
Arslan Ahmad is the lead author of Grokking Concurrency in Python. As the founder of Design Gurus and a former FAANG hiring manager, he has worked at industry giants like Facebook (now Meta) and Microsoft.
He has conducted hundreds of system design interviews, giving him unique insight into what top tech companies look for in candidates.
The course also incorporates expertise from senior engineers at Google, Meta, Amazon, Microsoft, and Uber, ensuring you learn system design best practices from professionals who have built and scaled real-world systems.
500+
Interviews Conducted
10k+
Students Taught
Related Courses
$98
$48
$48
FAQs
Who is this course for?
Engineers who write Python at work and have used threads or async at least once, even if the result surprised them: a request that blocked a whole service, a process pool that hung on exit, or a test that failed one time in fifty. By the end you can choose a concurrency model for a workload and support the choice with a measurement.
What should I know before I start?
You should be comfortable writing Python functions, classes and modules, and you should have run some code with threads or asyncio. You do not need to have used them well. The course builds the model of CPython that every later choice depends on before it uses any concurrency tool.
Which Python version does it use?
Every output in the course comes from Python 3.15.2, on both the standard build with the GIL and the free-threaded build without it. Python 3.14 is the baseline, and where a feature needs a newer version or a particular build, the lesson says so where the feature appears.
What is Harvest?
Harvest is a small web crawler and search indexer that the course builds one piece at a time. Fetching a page is mostly waiting, and indexing a page keeps a CPU busy, so the one program shows where threads and asyncio help and where only parallel execution does. It crawls a test site on the same machine that answers after a fixed delay, so every timing can be repeated and explained.
Are the outputs real?
Yes. Every program in the course ran, and each lesson shows the code next to the exact output it printed, with every timing in the text taken from that output. Each lesson names its machine: a Windows desktop with an 8 core AMD Ryzen 7 5800X for parallel work, or a Linux virtual machine for start methods, signals and production diagnostic tools.
Will it help me choose between threads, processes and asyncio?
That is the main goal of the course. The first chapter explains the four models and how to size each one, and a later chapter gives a decision framework and then measures asyncio against threads for IO bound work and compares four options for CPU bound work on both builds of CPython.
Does it cover free-threaded Python and subinterpreters?
Yes, in depth. You measure how the free-threaded build scales and what a single thread pays for it, find the data races that the GIL used to hide, audit compiled dependencies, run asyncio on it, and plan a migration with a way back. You also run code in subinterpreters with InterpreterPoolExecutor and see what crosses between them.
Does it cover libraries beyond the standard library?
Where they matter in practice. It compares TaskGroup with the nurseries and cancel scopes of Trio and AnyIO, tests async code with pytest-asyncio, profiles with py-spy, measures the thread pool behind def endpoints in FastAPI and Starlette, and explains what ThreadSanitizer finds in compiled extensions.
Does it cover testing and debugging concurrent code?
Yes. You make races happen on demand with a barrier, test deadlines and rate limits with virtual time instead of real waiting, and stress code until rare races appear. You then find a blocked event loop, a stuck task, a deadlock, a leak and GIL contention in a running process with the tools that production servers use.
Is there any practice, or is it only reading?
Every lesson closes with Key Takeaways and practice questions with folded answers. Each chapter before the capstone ends with a quiz that draws a fresh set of questions from a larger bank on every attempt, and the course ends with a capstone that runs failure drills on the finished Harvest, practice problems, and a final exam that covers every chapter.
Does it help with concurrency interview questions?
The Practice Problems chapter builds a blocking queue, a read-write lock, a rate limiter shared by threads and a concurrent web crawler, which are common interview problems. The rest of the course is written for production work. For interview preparation, Grokking Multithreading and Concurrency for Coding Interviews is the better fit.
How is it different from Grokking Concurrency in Go?
The two courses share an approach but not a runtime. Go schedules goroutines across all cores from the start, while CPython adds the GIL, separate processes, an event loop, a free-threaded build and subinterpreters, and most of this course is about choosing among them and measuring the result.