Skip to main content

python-timeout-iterator

timeout-iterator provides a timeout in iteration.

Python PyPI version codecov License

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

Metadata

Release files for timeout-iterator 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for timeout-iterator 0.2.2
File Size Uploaded
timeout_iterator-0.2.2.tar.gz 31.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for timeout-iterator 0.2.2
File Interpreter ABI Platform
timeout_iterator-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 36.6 kB

Release files / timeout_iterator-0.2.2.tar.gz

Download URL timeout_iterator-0.2.2.tar.gz
Size 31.2 kB
Tags Source
SHA-256 checksum
How to use checksums
08198cc131e9ea29e04515b4789799e809ebcd00c140a785eee3fcccc7e87ce1
BLAKE2b-256 checksum
How to use checksums
7fddac63f04f83ecdf401ab7fbe54ce451ae9df8f65beb918c7ca702526290d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / timeout_iterator-0.2.2-py3-none-any.whl

Download URL timeout_iterator-0.2.2-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
725425bbbcc805dec00fd9a41fde98e1aa2c3f23fc3a8241b031a8e96c05ff01
BLAKE2b-256 checksum
How to use checksums
4634d0f4fb9a7d20c694e4ec3561a344582c68c10472c78a142fac98d4017843
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page