async-timeout: Timeout Context Manager for Asyncio Programs

5.0.1 · active · verified Sat Mar 28

Provides a timeout context manager for asyncio programs, allowing for easy management of timeouts in asynchronous code. Current version: 5.0.1. Maintained with regular updates.

Warnings

Install

Imports

Quickstart

Demonstrates usage of the timeout context manager to set a 10-second timeout for an asynchronous operation.

import asyncio
from async_timeout import timeout

async def main():
    async with timeout(10):
        await asyncio.sleep(5)
        print('Completed within timeout')

asyncio.run(main())

view raw JSON →