The event-loop mental model
P33.event-loop.01 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: Context managers & yield as a doorway
Where next?
Later in The Event Loop
Go up a level
P33.event-loop.01 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: Context managers & yield as a doorway
Later in The Event Loop
Go up a level
async/await feels like new magic, but it is the generator machinery you
already know (P29), pointed at concurrency. Before touching asyncio, you'll
build an event loop by hand — a scheduler that takes turns stepping suspended
functions — so the real one holds no mysteries.
yield, hands control back, and resumes from exactly that point next time you step it. That is the one primitive an event loop needs: a unit of work that can voluntarily pause and be resumed later.Why it matters — Once you see that a generator is a function you can stop and restart, a coroutine is no longer exotic — it is the same object with nicer syntax.
Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.
Off by default. The mentor always gets your file; this only decides whether your own copy stays here. Copies live in this browser only - they do not follow you to another device, and clearing site data removes them.
Build the loop yourself over generators, then put the mental model into words.
Loading exercise…
Loading exercise…
You built the scheduler; the next module hands you the real one — asyncio —
where gather, timeouts and TaskGroups run genuine coroutines. Those rungs run
on the kernel, because real asyncio needs a real Python event loop.
Loading your notes...