asyncio
Installation
SKILL.md
asyncio Internals Reference
CPython 3.11 baseline. Version-specific differences noted for 3.12+ (eager task factory, eager_start) and 3.13+ (free-threaded, per-thread task state).
The Event Loop Cycle: _run_once
Every run_forever() call loops over _run_once(). One iteration:
1. Process _scheduled heap (timers due → move to _ready)
2. Poll I/O via selector (select/epoll/kqueue with timeout)
3. Process _ready deque (callbacks, exactly ntodo items)
Source: Lib/asyncio/base_events.py:BaseEventLoop._run_once