Iterator with timeout
Project description
python-timeout-iterator
timeout-iterator provides a timeout in iteration.
Installation
$ pip install timeout-iterator
Usage
without_terminate
without_terminate is a generator that it will not yield after the timeout,
but it will not raise an exception.
from timeout_iterator import without_terminate
results = []
for i in without_terminate(range(10), seconds=0.3):
results.append(i)
time.sleep(0.1)
assert results == [0, 1, 2]
terminate
terminate is a generator that it will raise an exception after the timeout.
from timeout_iterator import terminate
try:
results = []
for i in terminate(range(10), seconds=0.3):
results.append(i)
time.sleep(0.1)
except TimeoutError:
pass
assert results == [0, 1, 2]
LICENSE
BSD 3-Clause License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
timeout_iterator-0.2.2.tar.gz
(31.2 kB
view details)
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 timeout_iterator-0.2.2.tar.gz.
File metadata
- Download URL: timeout_iterator-0.2.2.tar.gz
- Upload date:
- Size: 31.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08198cc131e9ea29e04515b4789799e809ebcd00c140a785eee3fcccc7e87ce1
|
|
| MD5 |
d35df4117c482def4f8a6c55a355c967
|
|
| BLAKE2b-256 |
7fddac63f04f83ecdf401ab7fbe54ce451ae9df8f65beb918c7ca702526290d4
|
File details
Details for the file timeout_iterator-0.2.2-py3-none-any.whl.
File metadata
- Download URL: timeout_iterator-0.2.2-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
725425bbbcc805dec00fd9a41fde98e1aa2c3f23fc3a8241b031a8e96c05ff01
|
|
| MD5 |
2c4ceb10e0539766439ea882690cc851
|
|
| BLAKE2b-256 |
4634d0f4fb9a7d20c694e4ec3561a344582c68c10472c78a142fac98d4017843
|