Skip to main content

signalled-timeout

Timeout library for generic interruption of main thread by an exception after a configurable duration.

Use case

Set a timeout (seconds) upon expiration of which an exception is raised:

from timeout import timeout

…as a context manager:

with timeout(0.5):
    ... work ...

…or decorating a function:

@timeout(0.5)
def work():
    ...

The exception may be configured, either by passing an exception instance, or by specifying an overriding exception class and/or value(s):

with timeout(0.5, RuntimeError("Work took too long")):
    ... work ...

with timeout(0.5, RuntimeError, "Work took too long"):
    ... work ...

with timeout(0.5, exc=RuntimeError):
    ... work ...

with timeout(0.5, value="Work took too long"):
    ... work ...

with timeout(0.5, value=(2, "Took too long", 'work.py')):
    ... work ...

The timeout exception defaults to TimeoutError("Operation timed out").

Note: timeout is implemented via signal, and as such may not be applied outside of a process’s main thread.

Installation

signalled-timeout is a Python distribution, which may be installed via easy_install or pip, e.g.:

pip install signalled-timeout

…or, from source:

python setup.py install

Testing

To test the distribution on your system, execute its test command:

python setup.py test

Metadata

Release files for signalled-timeout 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for signalled-timeout 1.0.0
File Size Uploaded Provenance
signalled-timeout-1.0.0.tar.gz 2.7 kB Without provenance Details

Release files / signalled-timeout-1.0.0.tar.gz

Download URL signalled-timeout-1.0.0.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7fa88a7083a69e4c38b5f26e191a101a052dd39c85f5e79cbfb3ee38efb084f9
BLAKE2b-256 checksum
How to use checksums
98d10feeeb2ea3ca26388e06e1c4637fa4915519242a1f1a7a84076e60867d65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for signalled-timeout 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page