Dispatching work that becomes ready
An asynchronous program needs a mechanism for resuming suspended activities. An event loop connects I/O events, scheduled callbacks, and tasks, dispatching their handlers as work becomes ready rather than stopping the entire processing flow for every wait.
Python asyncio loops expose interfaces for running tasks, scheduling callbacks, opening network connections, and managing subprocesses. The loop provides runtime coordination; coroutine syntax still needs an environment that actually advances the resulting activities.
Callbacks and timers follow specified rules
Scheduling a callback does not mean executing it immediately. Asyncio call_soon arranges a later loop iteration and preserves registration order for those callbacks. Submission from another thread requires the appropriate thread-safe interface.
Delayed callbacks use the loop’s time base, which asyncio tracks with a monotonic clock. Callbacks scheduled for the same time have no guaranteed relative order. Clock resolution and pending work also matter, so a timer schedule is not an exclusive-processor real-time deadline.
References: [1]
Long-running work can still block dispatch
Long computation or a blocking file operation on the loop thread delays other callbacks and tasks. Having many concurrent tasks does not establish that they execute in parallel on multiple processors.
Asyncio can delegate suitable work to thread or process executors and connect the result back to the loop. This separation still requires limits on outstanding work and resources. Giving a function an asynchronous wrapper does not remove blocking behavior within its body.