stopit
Timeout control decorator and context managers, raise any exception in another thread
What it is and what it does
stopit provides two main mechanisms for controlling execution time in Python: context managers and decorators that enforce timeouts on code blocks and function calls. The core capability is raising asynchronous exceptions in other threads, including the main thread, to interrupt long-running operations. It offers ThreadingTimeout (a context manager) and threading_timeoutable (a decorator) for timeout control, plus async_raise for direct thread interruption. The package also provides a TimeoutException that signals when a timeout has occurred.
The package is tightly coupled to CPython's threading implementation and uses low-level APIs that are not available on alternative Python implementations. It has important limitations: it cannot interrupt blocking Python atomic instructions that hold the GIL (such as time.sleep), and signal-based timeout controls do not work on Windows. The package is no longer maintained, with its last release in 2018-02-09.
Use it for:
- Enforce maximum execution time on web request handlers or API calls that might hang indefinitely.
- Interrupt long-running computations or data processing tasks if they exceed a time budget.
- Implement watchdog timers for background worker threads that may become stuck.
- Decorate functions to return a default value if they do not complete within a specified timeout.
- Control timeout behavior in test suites to fail tests that run longer than expected.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides context managers and decorators to enforce timeouts on code blocks and function calls, and raise exceptions asynchronously in other threads.
No. The package is abandoned (last release 2018-02-09) with no maintenance signal. It relies on CPython-specific internals, does not work on alternative implementations, and has known limitations with GIL-blocking operations and Windows compatibility. For modern Python projects, consider maintained alternatives or the standard library's asyncio timeout mechanisms.
Install
stopit on PyPI
pip
pip install stopituv
uv add stopitpoetry
poetry add stopitInstalling stopit
Before you install
High install friction: the package is abandoned (last release 2018-02-09, 3108 days ago) and has no runtime dependencies. Threading-based timeout control relies on CPython-specific low-level APIs and will not work on alternative Python implementations (Jython, PyPy, IronPython). Signal-based timeouts do not work on Windows.
License in practice
Licensed under GPLv3 (permissive treatment noted), which permits use but requires derivative works to be distributed under the same license if distributed at all.
Quickstart
import stopit
with stopit.ThreadingTimeout(10) as to_ctx_mgr:
# code that may take too long
pass
if to_ctx_mgr.state == to_ctx_mgr.EXECUTED:
print('Completed within timeout')
Requires CPython; will not work on Jython, PyPy, or IronPython. Signal-based timeout control unavailable on Windows.
Verify before relying
- Whether the package works reliably on Python versions beyond 3.6 despite classifiers listing only up to 3.6.
- Current status of any known issues with GIL-blocking operations beyond the documented time.sleep() limitation.
- Whether the abandoned status poses compatibility or security risks for new projects.
Package facts
| License | GPLv3 (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | abandoned — 3,108 days since the last release |
| First released | |
| Downloads | 233,110/month — #9,046 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: stopit-1.1.2.tar.gz
Keywords: threads, timeout
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
func-timeoutRuns any Python function with a specified…
copyleft · top 5,000 on PyPI
timeout-decoratorA decorator that enforces time limits on…
permissive · top 5,000 on PyPI
pytest-timeoutAborts pytest tests that exceed a specified…
permissive · top 1,000 on PyPI
interruptingcowInterrupts long-running Python code by raising…
permissive · top 15,000 on PyPI
async-timeoutProvides an asyncio-compatible timeout context…
permissive · top 1,000 on PyPI
async-interruptProvides an asyncio context manager that…
permissive · top 5,000 on PyPI
PebblePebble provides decorators and pool…
copyleft · top 5,000 on PyPI
kthreadKThread provides a way to forcefully terminate…
permissive · top 15,000 on PyPI
jaraco.contextProvides decorators and context managers for…
permissive · top 1,000 on PyPI
crochetCrochet lets you call Twisted asynchronous code…
permissive · top 15,000 on PyPI