Timeout-Timer
Installation
python setup.py install
Timeout Timer
Add a timeout function to a function or statement and raise a exception if time limit runs out, can work as a context or decorator, support loop nesting and should use diff exception class, if use signal timer, outside timer will fired after the inside signal timer finish the work(raise exception or normal finish).
Support signal timer and thread timer, signal timer can only work on main thread, if not on main thread use thread timer, thread timer may cost longer time than time out seconds settled if the user’s function is busy in a system call (time.sleep(), socket.accept()…), exception will fired after system call done.
Usage
support nested loop
from timeout_timer import timeout, TimeoutInterrupt
class TimeoutInterruptNested(TimeoutInterrupt):
pass
def test_timeout_nested_loop_both_timeout(timer):
cnt = 0
try:
with timeout(5, timer=timer):
try:
with timeout(2, timer=timer, exception=TimeoutInterruptNested):
sleep(2)
except TimeoutInterruptNested:
cnt += 1
time.sleep(10)
except TimeoutInterrupt:
cnt += 1
assert cnt == 2
use as decorator
@timeout(2):
def f():
time.sleep(3)
time.sleep(2)
License
Code released under the MIT license
Metadata
Release files for timeout-timer 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| timeout-timer-0.2.0.tar.gz | 5.6 kB | Without provenance | Details for timeout-timer-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| timeout_timer-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for timeout_timer-0.2.0-py3-none-any.whl |
Total release size: 12.0 kB
Release files / timeout-timer-0.2.0.tar.gz
| Download URL | timeout-timer-0.2.0.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e33a32dd03148527272348faa38cc6844e591948e1ce8042938de3c592751384
|
|
BLAKE2b-256 checksum How to use checksums |
d3587bbcf7a85ce7542aa71b245a199477b614229c44fbb1d7f2e42e11fe4f0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
|
Release files / timeout_timer-0.2.0-py3-none-any.whl
| Download URL | timeout_timer-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
67c512191e422849b7aa6157b978b2b354b139b23b44d9f311011e7a5f6b2300
|
|
BLAKE2b-256 checksum How to use checksums |
79c8768c9b08ce4d0a57b247f6cca9aab4b0349bfcf8ca76952b4b4fd6e3c17c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
|
Security for timeout-timer 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.