Timeout context manager for asyncio programs
Project description
async_timeout
asyncio-compatible timeout context manager.
Usage example
The context manager is useful in cases when you want to apply timeout logic around block of code or in cases when asyncio.wait_for() is not suitable. Also it’s much faster than asyncio.wait_for() because timeout doesn’t create a new task.
The timeout(timeout, *, loop=None) call returns a context manager that cancels a block on timeout expiring:
with timeout(1.5): yield from inner()
If inner() is executed faster than in 1.5 seconds nothing happens.
Otherwise inner() is cancelled internally by sending asyncio.CancelledError into but asyncio.TimeoutError is raised outside of context manager scope.
timeout parameter could be None for skipping timeout functionality.
Installation
$ pip install async_timeout
The library is Python 3 only!
CHANGES
1.0.0 (2016-09-XX)
The first release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for async_timeout-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d3fd64572c13b75f9f1cbb7e7de089cc7ae119a26913573813a9124651df923 |
|
MD5 | 2dec8641f93ae9b6410927673c88068c |
|
BLAKE2b-256 | b4e65dc387267854666df7d2e5e5a305c8b2e037056bdf8bb278aed488670598 |