Async I/O in Python
Use asyncio to run many I/O-bound operations concurrently in a service without blocking the event loop.
3 objectives 5 steps about 105 min
Learn it step by step
Read the lessons in order, try the practice checks, then prove the skill with the knowledge check.
This skill page is a public outline. Its lessons and knowledge check appear here as subject-matter experts approve them.
Learning objectives
- Explain how the event loop schedules coroutines and predict whether a piece of async code runs concurrently or sequentially.
- Run concurrent I/O with task groups or gather, bounding concurrency with a semaphore and applying timeouts and cancellation.
- Detect a blocking call inside an async endpoint and fix it by switching to an async library, a plain def endpoint or a thread-pool offload.
Lesson plan
5 steps, about 105 min · 4 of 4 lessons available so far
- Concurrency for I/O: The Event Loop Mental Model Concept · 20 min
- Coroutines, Tasks and Task Groups Worked example · 25 min
- Timeouts, Cancellation and Bounded Concurrency Worked example · 20 min
- Lab: Find the Call That Blocks the Loop Lab · 25 min
- Check: Sequential, Concurrent or Blocked? Knowledge check · 6 questions
Practise it
Write an async endpoint that fans out to three slow upstream services with httpx.AsyncClient, caps concurrency, enforces an overall timeout and returns partial results; then show with timing logs that a deliberately blocking call stalls other requests, and fix it.
Build it from scratch
Practice builds that exercise this skill by re-creating a real technology.
- Build your own Chat ServerIntermediate · 8–16 h
References
Hard prerequisites
Unlocks
On these roadmaps
Progress and evidence for this skill are shared across all of them.