Skip to main content

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

Project description

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

Project details


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 hashes)

Uploaded Source

Built Distribution

timeoutcall-1.0-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page