Skip to main content

execute with timeout

Project description

timeout-executor

License: MIT github action PyPI version python version

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


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.14.tar.gz (20.7 kB view hashes)

Uploaded Source

Built Distribution

timeout_executor-0.1.14-py3-none-any.whl (31.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page