Skip to main content

call_function_with_timeout

A library to make your funtions support timeouts

Example

import time
from call_function_with_timeout import SetTimeout

# make your function
def do_something(a=0, b=0):
    time.sleep(10)
    print(a + b)

# define function with timeout
func_with_timeout = SetTimeout(do_something, timeout=5)
# call the function
is_done, is_timeout, erro_message, results = func_with_timeout(a=12, b=8)

You will find that after the method is called to the time you specified, it will return and kill the currently executing thread.

You can also use it as a decorator

import time
from call_function_with_timeout import SetTimeoutDecorator

# make your function with timeout
@SetTimeoutDecorator(timeout=5)
def do_something(a=0, b=0):
    time.sleep(10)
    print(a + b)

# call the function
is_done, is_timeout, erro_message, results = do_something(a=12, b=8)

Metadata

Release files for call-function-with-timeout 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for call-function-with-timeout 1.1.1
File Size Uploaded
call_function_with_timeout-1.1.1.tar.gz 3.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for call-function-with-timeout 1.1.1
File Interpreter ABI Platform
call_function_with_timeout-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / call_function_with_timeout-1.1.1.tar.gz

Download URL call_function_with_timeout-1.1.1.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f4ebd4c67d72d53772ce039540fbfeffc9dfadd31574aec171b830925706cdd6
BLAKE2b-256 checksum
How to use checksums
cba224526b29a9ff80a5388504b13f04413d5a13e703be43a64cc61a99785ee3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / call_function_with_timeout-1.1.1-py3-none-any.whl

Download URL call_function_with_timeout-1.1.1-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2af11d65db1c733a30b15445f492fd5c98432154afba2455bf89c6f9e7ef0a30
BLAKE2b-256 checksum
How to use checksums
e55e1ccbaf71a609d62548f08a050dbfc47ca066ce39df5f53a1a875795f2bcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page