{"id":28390,"library":"timeoutcontext","title":"timeoutcontext","description":"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).","status":"active","version":"2.0.0","language":"python","source_language":"en","source_url":"https://github.com/AntoineCezar/timeoutcontext","tags":["timeout","context manager","signal"],"install":[{"cmd":"pip install timeoutcontext","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":"","wrong":"","symbol":"timeout","correct":"from timeoutcontext import timeout"}],"quickstart":{"code":"from timeoutcontext import timeout\nimport time\ntry:\n    with timeout(2):\n        time.sleep(5)\n        print('Completed')\nexcept TimeoutError:\n    print('Operation timed out')","lang":"python","description":"Basic usage: wrap long-running operations in a `with timeout(seconds)` block. Raises TimeoutError if time exceeded."},"warnings":[{"fix":"Use `except TimeoutError` instead of `except Timeout`. Update Python requirement to >=3.10.","message":"Version 2.0.0 dropped support for Python <3.10. The exception changed from `Timeout` (custom) to the built-in `TimeoutError`.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Use on Unix/Linux/macOS for correct behavior. On Windows, consider alternative libraries like `stopit` or `threading.Timer`.","message":"The 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.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"timeoutcontext will silently not timeout on Windows. Use on Unix or handle unsupported OS explicitly.","cause":"Running on Windows where SIGALRM is not available.","error":"AttributeError: module 'signal' has no attribute 'SIGALRM'"},{"fix":"Import TimeoutError from timeoutcontext: `from timeoutcontext import TimeoutError` or catch the built-in `TimeoutError` directly (Python 3.11+).","cause":"Version 2.0.0 renamed the exception to TimeoutError.","error":"NameError: name 'Timeout' is not defined"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}