Skip to content

A package designed to kill a function after a specified amount of time.

License

Notifications You must be signed in to change notification settings

xyzpw/timeoutcall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

timeoutcall

python requires Pepy Total Downlods GitHub repo size PyPI - Version

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 increment n 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

About

A package designed to kill a function after a specified amount of time.

Topics

Resources

License

Stars

Watchers

Forks

Languages