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.10.tar.gz
(14.3 kB
view hashes)
Built Distribution
Close
Hashes for timeout_executor-0.1.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e2ec0ea2bdebbc49831a6d4f9dd6d1467792c5abf7637018ed568f59e0e67e1 |
|
MD5 | 36af3ed7d14fa6b01f2106e8b97f5764 |
|
BLAKE2b-256 | 4de3a2978957f9a2caac94c5eb9c41f413223fa9706cc31ab0d6d941df244216 |