Async agents and concurrency
Notebook· 12.03· 2–3 h· Lesson 102 of 129
The notebook opens in your lab, in a new tab. If your server is stopped, it starts first (a few seconds).
By the end you can
- Explain how one event loop serves many runs, and what blocks it.
- Find and fix blocking code inside async agents (
time.sleep, sync clients) withawaitorasyncio.to_thread. - Know where sync code runs in an async server (a thread pool), and the limit that pool sets.
- Run many agent runs at once with a concurrency limit and a bounded queue, and measure queue time against the latency budget of 12.01.
- Apply timeouts and cancellation without leaving work half done.
- Size concurrency from the provider's rate limit with Little's law.
Before you start
Lessons 12.01–12.02, Module 02 (streaming) and Project 09 (the support desk).
Python in this lesson
Python guideNew herelogging
