Interruptingcow is a generic utility designed to gracefully interrupt Python code that exceeds a specified execution time. It achieves this by utilizing the `signal(SIGALRM)` mechanism. The current version is 0.8, with an infrequent release cadence, as the last update was in 2018.
pip install interruptingcowVerified import paths — ran on the pinned version, not inferred.
The primary use case is wrapping potentially long-running code in a `with timeout(...)` block. If the code inside the block exceeds the specified time, a `RuntimeError` (or a custom exception) is raised. Quotas can be used to limit total time across multiple calls.
Ensure critical sections requiring timeouts are run in the main thread or consider alternative asynchronous timeout mechanisms for multi-threaded applications (e.g., using `threading.Event` or `concurrent.futures`).
Avoid using `interruptingcow` in applications that manage `SIGALRM` directly. If unavoidable, carefully manage signal handlers to prevent conflicts, e.g., by saving and restoring existing handlers.
For new projects or environments running Python 3.6+, it is strongly recommended to use a more actively maintained timeout library or Python's built-in `signal` module directly. If `interruptingcow` must be used, ensure compatibility by restricting the Python interpreter to version 3.5 or earlier in a virtual environment.
This library is designed for older Python versions (up to 3.5). Downgrade your Python environment to 3.5 or earlier, or migrate to a different, actively maintained timeout library compatible with modern Python versions.
Refactor your code to execute the timed operation within the main thread, or use an alternative inter-thread communication mechanism (e.g., `threading.Event`, `queue` with a timeout, or `concurrent.futures.wait` with a timeout) if the operation must be performed in a separate thread.
No dependency data recorded yet.
No resource links recorded.