A package designed to kill a function after a specified amount of time.
Project description
timeoutcall
A package designed to kill a function after a specified amount of time.
Usage
[!WARNING] Timeout functions are their own processes, assigning values will not do so globally. Using
while True: n+=1
will not incrementn
globally.
Calling Functions
from timeoutcall import call
from time import sleep
def foo(n):
time.sleep(n) # raises TimeoutError
# given that `n` is greater than `timeoutSeconds`, an exception will occur
call(target=foo, timeoutSeconds=1, err_msg="error: took too long", n=5)
Decorators
from timeoutcall import timeout
from time import sleep
@timeout(2, "error: took too long")
def foo():
sleep(3) # will raise TimeoutError
foo()
Package Testing
$ python3 -m timeoutcall.test
$ python3 -m timeoutcall.testcall
Developers
Build and Source Distributions
To build the wheel and source distributions:
- cd into the repositories root directory
- run
python3 -m build
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
timeoutcall-1.0.tar.gz
(4.0 kB
view details)
Built Distribution
File details
Details for the file timeoutcall-1.0.tar.gz
.
File metadata
- Download URL: timeoutcall-1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b1290f0e278e1a1a9ab0d678d29d5a6ed3a6bf7217705e4bf91cd41c2c94387 |
|
MD5 | 4607c0abcd34c22ac395303d326534a0 |
|
BLAKE2b-256 | 5da21f88e274185ce6d12897b2f5553b932081242547cfd9213d31e57b69c288 |
File details
Details for the file timeoutcall-1.0-py3-none-any.whl
.
File metadata
- Download URL: timeoutcall-1.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9c84a6ec4e2ddbac1ceb525dcc3bece1138026c286924c04df29664d83656bf |
|
MD5 | 2f85aefa42a67d85ba04a2449b73c948 |
|
BLAKE2b-256 | ad595a62d41d15d6e8a98b7c25fbd423480d99450c52d9345b2e01b8ccb3538b |