asyncio
While doing Python’s Websockets tutorial, I encountered asyncio library and used async/await for the tutorial code.
asyncio is a Python library used to write concurrent code using async/await syntax.
- Single-threaded & single-process design
- It uses cooperative multitasking
- A style of concurrent programming but not parallelism (more closely aligned with threading)
- Related concepts: callbacks, events, transports, protocols, futures
Coroutine
- A specialized version of a Python generator function that can suspend its execution before reaching
returnand that can indirectly pass control to another coroutine for some time