This is a simple explanation of the asyncio
module and new supporting language
features in Python 3.5. Even though the new keywords async
and await
are new
language constructs, they are mostly1 useless without an event loop, and that
is supplied in the standard library as asyncio
. Also, you need awaitable
functions, which are only supplied by asyncio
(or in the growing set of async
libraries, like asyncssh
, quamash
etc.).
A little example of how asyncio works
This is a simple example to show how Asyncio works without using Asyncio itself, instead using a basic and poorly written event loop. This is only meant to give a flavor of what Asyncio does behind the curtains. I’m avoiding most details of the library design, like callbacks, just to keep this simple. Since this is written as an illustration, rather than real code, I’m going to dispense with trying to keep it 2.7 compatible.
[Read More]