A package designed to kill a function after a specified amount of time.
Warning
Timeout functions are their own processes, assigning values will not do so globally.
Using while True: n+=1
will not increment n
globally.
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)
from timeoutcall import timeout
from time import sleep
@timeout(2, "error: took too long")
def foo():
sleep(3) # will raise TimeoutError
foo()
$ python3 -m timeoutcall.test
$ python3 -m timeoutcall.testcall
To build the wheel and source distributions:
- cd into the repositories root directory
- run
python3 -m build