Async Python and Concurrency
Master Python concurrency — asyncio, threading, multiprocessing, and task orchestration for I/O-bound and CPU-bound workloads.
View badge details
About This Course
Demystify Python's concurrency models. This course teaches the GIL and when it matters, threading for I/O-bound tasks, asyncio for single-threaded concurrency, async HTTP/file/database I/O, task orchestration with semaphores and producer/consumer patterns, and multiprocessing for CPU-bound work. Every lesson uses realistic scenarios with measurable performance differences. The capstone builds a concurrent data pipeline that ingests from multiple sources, processes in parallel, and handles errors gracefully. Requires solid Python experience with FastAPI and testing. Course 7 of 10 in the Python Learning Path.
Course Curriculum
12 Lessons
The GIL, Threads, and Processes
AI-led teaching lesson (6 topics x 8 beats, 12 diagrams) covering the CPython GIL, threads for IO-bound work (threading + ThreadPoolExecutor), processes for CPU-bound work (multiprocessing + ProcessPoolExecutor), the asyncio event loop (structured concurrency + TaskGroup), a decision framework for choosing between the three, and PEP 703 free-threaded Python 3.13. Fictional company: StreamForge; fictional principal engineer: Kara Nguyen.
The GIL Threads and Processes - Lab Exercises
Concurrency vs parallelism, the GIL (what it is/prevents/why it exists), threading.Thread and shared state risks, thread safety with Lock and Queue, ThreadPoolExecutor for I/O-bound tasks
asyncio Fundamentals
AI-led teaching session covering event loop and single-threaded concurrency, async def and await, asyncio.create_task and gather/wait, awaitables (coroutines vs tasks vs futures), and common mistakes (forgetting await, blocking calls). Fictional company: StreamForge.
asyncio Fundamentals - Lab Exercises
Event loop and single-threaded concurrency, async def and await, asyncio.create_task and gather/wait, awaitables (coroutines vs tasks vs futures), common mistakes (forgetting await, blocking calls)
Async IO HTTP Files and Databases
AI-led teaching session covering aiohttp ClientSession and connection pooling, httpx AsyncClient for async HTTP, aiofiles for async file I/O, aiosqlite for async database, and mixing sync and async with asyncio.to_thread. Fictional company: StreamForge.
Async IO HTTP Files and Databases - Lab Exercises
aiohttp ClientSession and connection pooling, httpx AsyncClient for async HTTP, aiofiles for async file I/O, aiosqlite for async database, mixing sync and async with asyncio.to_thread
Task Orchestration and Patterns
AI-led teaching session covering semaphores for rate limiting, timeouts with wait_for and asyncio.timeout, error handling with return_exceptions and TaskGroup, producer/consumer with asyncio.Queue, and retry with exponential backoff and jitter. Fictional company: StreamForge.
Task Orchestration and Patterns - Lab Exercises
Semaphores for rate limiting, timeouts with wait_for and asyncio.timeout, error handling with return_exceptions and TaskGroup, producer/consumer with asyncio.Queue, retry with exponential backoff and jitter
multiprocessing for CPU-Bound Work
AI-led teaching session covering when to use multiprocessing vs async, ProcessPoolExecutor with map and submit, pickle constraints for cross-process data, shared state with Value and Queue, and decision tree (I/O-bound vs CPU-bound vs mixed). Fictional company: StreamForge.
multiprocessing for CPU-Bound Work - Lab Exercises
When to use multiprocessing vs async, ProcessPoolExecutor with map and submit, pickle constraints for cross-process data, shared state with Value and Queue, decision tree (I/O-bound vs CPU-bound vs mixed)
Capstone Briefing Concurrent Data Pipeline
AI-led capstone briefing covering the design and architecture of a concurrent data pipeline with async HTTP ingestion, producer/consumer queues, CPU-bound processing via ProcessPoolExecutor, error handling with timeouts and retries, and performance metrics. Fictional company: StreamForge.
Capstone Concurrent Data Pipeline
Capstone: build concurrent pipeline with async HTTP ingestion from 10 sources with rate limiting, producer/consumer queue with 3 async workers, CPU-bound processing via ProcessPoolExecutor, error handling with timeouts and retries, JSON output with performance metrics