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[loky]"
# 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.2.1.tar.gz
(20.2 kB
view hashes)
Built Distribution
Close
Hashes for timeout_executor-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4819e1db0f13704946e38825e08a280af312ee9879214d3c5ef67aad2c174ed0 |
|
MD5 | 229823a46896625a9d596e1e4e3d61ee |
|
BLAKE2b-256 | 45b22113e63f73a135e81b9b3ce6834a156d7e21bd499a4ec13d0f7551c4c9ea |