async-timeout: Timeout Context Manager for Asyncio Programs
raw JSON → 5.0.1 verified Tue May 12 auth: no python install: verified quickstart: verified
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.
pip install async-timeout Common errors
error ModuleNotFoundError: No module named 'async_timeout' ↓
cause The 'async_timeout' module is not installed in the Python environment.
fix
Install the module using pip: 'pip install async-timeout'.
error ImportError: cannot import name 'timeout' from 'async_timeout' ↓
cause The 'timeout' function is not available in the 'async_timeout' module, possibly due to an outdated version.
fix
Ensure you have the latest version installed: 'pip install --upgrade async-timeout'.
error AttributeError: module 'async_timeout' has no attribute 'timeout' ↓
cause The 'timeout' attribute is missing from the 'async_timeout' module, likely due to an incorrect installation or version.
fix
Verify the installation and version: 'pip show async-timeout' and upgrade if necessary.
error TypeError: timeout() got an unexpected keyword argument 'timeout' ↓
cause This issue arises when calling the `timeout` context manager with a keyword argument named `timeout`, while the function expects the duration as a positional argument or a different keyword like `delay`.
fix
Pass the timeout duration as the first positional argument, for example:
async with timeout(5.0): instead of async with timeout(timeout=5.0):. error asyncio.TimeoutError ↓
cause The asynchronous operation wrapped by the `async_timeout.timeout` context manager did not complete within the specified time limit, causing a `asyncio.TimeoutError` to be raised.
fix
Handle the
asyncio.TimeoutError exception using a try...except block, increase the timeout duration if the operation legitimately takes longer, or optimize the underlying asynchronous code to complete faster. Warnings
breaking Version 5.0.0 introduced changes to the 'timeout' function, making it fully compatible with the standard 'asyncio.Timeout'. ↓
fix Update your code to use the new 'timeout' function signature and behavior.
deprecated Support for Python 3.6 was dropped in version 4.0.3. ↓
fix Upgrade your Python environment to version 3.7 or higher.
Install compatibility verified last tested: 2026-05-12
python os / libc status wheel install import disk
3.10 alpine (musl) - - 0.08s 17.8M
3.10 slim (glibc) - - 0.06s 18M
3.11 alpine (musl) - - 0.16s 19.6M
3.11 slim (glibc) - - 0.14s 20M
3.12 alpine (musl) - - 0.38s 11.5M
3.12 slim (glibc) - - 0.33s 12M
3.13 alpine (musl) - - 0.40s 11.2M
3.13 slim (glibc) - - 0.33s 12M
3.9 alpine (musl) - - 0.08s 17.3M
3.9 slim (glibc) - - 0.07s 18M
Imports
- Timeout
from async_timeout import timeout
Quickstart verified last tested: 2026-04-23
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())