Skip to content

asyncio

asyncio is a library to write concurrent code using the async/await syntax.

asyncio is used as a foundation for multiple Python asynchronous frameworks that provide high-performance network and web-servers, database connection libraries, distributed task queues, etc.

asyncio is often a perfect fit for IO-bound and high-level structured network code.

Note

"[Asyncer](https://asyncer.tiangolo.com/tutorial/) looks very useful"

Tips⚑

Limit concurrency⚑

Use asyncio.Semaphore.

sem = asyncio.Semaphore(10)
async with sem:
    # work with shared resource

Note that this method is not thread-safe.

References⚑

Libraries to explore⚑