execute with timeout
Project description
timeout-executor
how to install
$ pip install timeout_executor
# or
$ pip install "timeout_executor[uvloop]"
how to use
from __future__ import annotations
import time
from timeout_executor import AsyncResult, 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)
result = executor.apply(lambda: "done")
assert isinstance(result, AsyncResult)
value = result.result()
assert value == "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.3.1.tar.gz
(10.3 kB
view hashes)
Built Distribution
Close
Hashes for timeout_executor-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 396183b5b95c4d9f895e8812a717776f48df2edc283aaa71a9b2b735d2a6469a |
|
MD5 | d54d2631f691e86a141a878dbfb952f3 |
|
BLAKE2b-256 | 4975b238e4261fdbcdf6ca2a0aee661d8abd3e494abf374ed205b6c18ebd9fdd |