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.

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


Last update: 2022-02-17