Iterator with timeout
Project description
python-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
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
timeout-iterator-0.1.0.tar.gz
(15.3 kB
view details)
Built Distribution
File details
Details for the file timeout-iterator-0.1.0.tar.gz
.
File metadata
- Download URL: timeout-iterator-0.1.0.tar.gz
- Upload date:
- Size: 15.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6153073b8021f58d36ab7485e339a9443725b5162254c6b132ccc336cd1f2ecb |
|
MD5 | 823f5a17eaa61403d30cf05cdef9b23b |
|
BLAKE2b-256 | daf1c32dd8912aa8a577a8139393d91555cd4b2e30dc028c8f6a675f125e7529 |
File details
Details for the file timeout_iterator-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: timeout_iterator-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 760247fd9dd445e23e1b93aab4643926f54e2e209fd97f9873145f3c8984e9f3 |
|
MD5 | 6170b6c0f5a1ea36d5d8953bf0d74ffa |
|
BLAKE2b-256 | 57477229b584fe610241c45a46f55dd9372afd1c6e0f1fbacbe499274b8eb36b |