execute with timeout
Project description
timeout-executor
how to install
$ pip install timeout_executor
# or
$ pip install "timeout_executor[all]"
# or
$ pip install "timeout_executor[billiard]"
# or
$ pip install "timeout_executor[dill]"
# or
$ pip install "timeout_executor[cloudpickle]"
how to use
import time
from timeout_executor import TimeoutExecutor
def sample_func() -> None:
time.sleep(10)
executor = TimeoutExecutor(1)
try:
executor.apply(sample_func)
except Exception as exc:
assert isinstance(exc, TimeoutError)
executor = TimeoutExecutor(1, pickler="dill") # or cloudpickle
result = executor.apply(lambda: "done")
assert result == "done"
License
MIT, see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
timeout_executor-0.1.11.tar.gz
(19.2 kB
view hashes)
Built Distribution
Close
Hashes for timeout_executor-0.1.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7172b4d1e7fa5a9e842860851e20183f8ebf660d8d1519f1ccf75c249cbf87e |
|
MD5 | 87065e3fa4425c5df29963a1faf77b3d |
|
BLAKE2b-256 | 76a86e7db6b3cb29150a9329acb62425520ee866a2640a518cb246a0f7737589 |