Registry / http-networking / timeoutcontext

timeoutcontext

JSON →
library2.0.0pypypi✓ verified 84d ago

A signal-based timeout context manager for Python. Current version 2.0.0. Uses OS signals to interrupt long-running operations. Updated to require Python >=3.10. Release cadence is low (major versions separated by years).

pip install timeoutcontext
INSTALL
IMPORT
SIG · TIMEOUTCONTEXT
T
timeoutcontext
http-networkingpythonv2.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

timeout
from timeoutcontext import timeout

Basic usage: wrap long-running operations in a `with timeout(seconds)` block. Raises TimeoutError if time exceeded.

from timeoutcontext import timeout import time try: with timeout(2): time.sleep(5) print('Completed') except TimeoutError: print('Operation timed out')
Debug
Known issues
breakingVersion 2.0.0 dropped support for Python <3.10. The exception changed from `Timeout` (custom) to the built-in `TimeoutError`.
fix
Use `except TimeoutError` instead of `except Timeout`. Update Python requirement to >=3.10.
affects: <2.0.0
gotchaThe context manager uses SIGALRM on Unix. On Windows, signal-based timeouts are not supported; it will gracefully fall back to no timeout. Do not rely on timeout behavior on Windows.
fix
Use on Unix/Linux/macOS for correct behavior. On Windows, consider alternative libraries like `stopit` or `threading.Timer`.
affects: all
Errors
Common errors & fixes
AttributeError: module 'signal' has no attribute 'SIGALRM'
Running on Windows where SIGALRM is not available.
fix
timeoutcontext will silently not timeout on Windows. Use on Unix or handle unsupported OS explicitly.
NameError: name 'Timeout' is not defined
Version 2.0.0 renamed the exception to TimeoutError.
fix
Import TimeoutError from timeoutcontext: `from timeoutcontext import TimeoutError` or catch the built-in `TimeoutError` directly (Python 3.11+).
Upgrade
Version history
2.0.0latest on PyPI · released Nov 17, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
42 hits · last 30 days
node
38
OpenAI (training)
1
Resources
timeoutcontext — pip install timeoutcontext · libregistry