PyDocs

Nav

Networking and Interprocess Communication

timeout

asyncio

function · Added in 3.11 (source) not WASI
  • timeout(delay)
Timeout async context manager.

Useful in cases when you want to apply timeout logic around block
of code or in cases when asyncio.wait_for is not suitable. For example:

>>> async with asyncio.timeout(10):  # 10 seconds timeout
...     await long_running_task()


delay - value in seconds or None to disable timeout logic

long_running_task() is interrupted by raising asyncio.CancelledError,
the top-most affected timeout() context manager converts CancelledError
into TimeoutError.
0 Examples
No examples for asyncio/timeout.
See Also
No see-alsos for asyncio/timeout
0 Notes
No notes for timeout