call-function-with-timeout-1.1.1
توضیحات
Python Call function with timeouts
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | call-function-with-timeout-1.1.1 |
| نام | call-function-with-timeout |
| نسخه کتابخانه | 1.1.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Tony_9410 |
| ایمیل نویسنده | tony_9410@foxmail.com |
| آدرس صفحه اصلی | https://github.com/yang445786754/call_function_with_timeout |
| آدرس اینترنتی | https://pypi.org/project/call-function-with-timeout/ |
| مجوز | - |
# call_function_with_timeout
A library to make your funtions support timeouts
Example
```python
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
```python
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)
```
نیازمندی
| مقدار | نام |
|---|---|
| - | thread-with-results |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6 | Python |
نحوه نصب
نصب پکیج whl call-function-with-timeout-1.1.1:
pip install call-function-with-timeout-1.1.1.whl
نصب پکیج tar.gz call-function-with-timeout-1.1.1:
pip install call-function-with-timeout-1.1.1.tar.gz