Coroutine
Definition
Coroutines are a more generalized form of subroutines. Subroutines are entered at one point and exited at another point. Coroutines can be entered, exited, and resumed at many different points. They can be implemented with the async def statement. See also PEP 492.
Baby toy on top of generators
Expected output after calling from_user()
The control of the program is getting passed back and forth between these 2 functions. This is pretty much a baby version of asyncio
.
Basic async and await
definitions
coroutine - a function with
async def
awaitable - any object with
__await__
method (i.e.asyncio.Future
,asyncio.Task
)task - a wrapper around coroutine and gets scheduled by the event loop independently
event loop - scheduler
References
Last updated