Python Call function with timeouts
Project description
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)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file call_function_with_timeout-1.1.1.tar.gz.
File metadata
- Download URL: call_function_with_timeout-1.1.1.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4ebd4c67d72d53772ce039540fbfeffc9dfadd31574aec171b830925706cdd6
|
|
| MD5 |
cc01f14066659ab9fbbd73e973683b98
|
|
| BLAKE2b-256 |
cba224526b29a9ff80a5388504b13f04413d5a13e703be43a64cc61a99785ee3
|
File details
Details for the file call_function_with_timeout-1.1.1-py3-none-any.whl.
File metadata
- Download URL: call_function_with_timeout-1.1.1-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2af11d65db1c733a30b15445f492fd5c98432154afba2455bf89c6f9e7ef0a30
|
|
| MD5 |
8fd19ac51a0611a6097288e9c88fc66c
|
|
| BLAKE2b-256 |
e55e1ccbaf71a609d62548f08a050dbfc47ca066ce39df5f53a1a875795f2bcc
|