On this page
  1. asyncio.timeout
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

asyncio.timeout

Prev: asyncio.start_unix_server | Up: asyncio | Next: asyncio.timeout_at
Rel: asyncio.AbstractEventLoop, asyncio.AbstractServer, asyncio.all_tasks, asyncio.as_completed
Ref: docs.python.org — asyncio.timeout
Tags: #public #python3 #stdlib #asyncio


Import

import asyncio
from asyncio import timeout

Signature & Overview

asyncio.timeout(delay: float | None) -> asyncio.timeouts.Timeout

Timeout async context manager.

Usage

import asyncio

async def main():
    try:
        async with asyncio.timeout(0.01):
            await asyncio.sleep(1)
    except TimeoutError:
        assert True

asyncio.run(main())

Gotchas

REPL Inspect

from asyncio import timeout
help(timeout)

Linked from

Related notes