Timeout functionality for asynchronous iterators
Project description
aiter-timeouts
Timeout functionality for asynchronous iterators. Supports timeouts on the total time to exhaust an asynchronous iterator, or the time it takes for any given step.
Supports Python 3.7+.
Example
Just wrap your async iterator in a call to with_timeout, like so:
from aiter_timeouts import with_timeout
async def async_iter():
for i in range(10):
await asyncio.sleep(0.5)
yield i
try:
async for val in with_timeout(async_iter(), timeout=6, timeout_per_step=1):
...
except IterationTimeoutError as e:
print(f"step {e.step} took too long")
except IteratorTimeoutError as e:
print(f"only reached step {e.step} before timing out")
License
MIT License Copyright (c) 2023 Elias Gabriel
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiter_timeouts-1.1.0.tar.gz.
File metadata
- Download URL: aiter_timeouts-1.1.0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.10.3 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b201ce0c980f036158cd86bc83a1154ea13f2cc72dc37a6b427fdc590ec0439f
|
|
| MD5 |
e14bd451d2bb4b9dbef21c40c49185e7
|
|
| BLAKE2b-256 |
5dd656a412cbd13a8feaf8716a66616a7e464ed8a733fbbcdd44cf60379d82fd
|
File details
Details for the file aiter_timeouts-1.1.0-py3-none-any.whl.
File metadata
- Download URL: aiter_timeouts-1.1.0-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.10.3 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3077b64e35466f916fdac6de3bdb932869d13f786eb39d5365d0fb15d4762985
|
|
| MD5 |
816c5e4e89c15718682ebb1c122a3754
|
|
| BLAKE2b-256 |
7431970d16a1649c5b893e4e17beca5b548d048078a9e2a7a7f92b6a8f2a4cac
|