Asyncio
Definition
asyncio is a library included in Python 3.5 that supports a programming model where sometimes, operations that would normally block the thread until some other event happened (like getting a response from a network connection) instead allow other code to run on that thread while waiting.
asyncio takes a very, very explicit approach to asynchronous programming: only code written in methods flagged as async can call any code in an asynchronous way.
asyncio.run
This is new in Python 3.7
1 | import asyncio |
Socket with Asyncio
1 | import asyncio |
1 | output: (bash 1) |
1 | output: (bash 2) |