$npx skillfedfor your agent

wrapt-timeout-decorator

The better timout decorator

With conditionsPyPI Python ModulesReleased Feb 20242.2M downloads / moMITPure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — wrapt_timeout_decorator-1.5.1-py3-none-any.whl
v1.5.1 · released 2024-02-28 · Python >=3.8.0 · 6 runtime deps: cli-exit-tools, lib-detect-testenv, multiprocess, psutil, wrapt, dill

Yes, if you need a robust timeout decorator that handles methods and classes correctly and works cross-platform. The package is actively maintained, has no known vulnerabilities, and low install friction. However, reserve it as a last resort after checking whether the libraries you're calling already offer native timeout support; the subprocess overhead on Windows and repeated invocations can be significant. Ensure your decorated function arguments are pickleable.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • On Windows, subprocess strategy is the only option (signals unavailable); on POSIX systems, signals cannot be used within subthreads.
  • Requires Python 3.8.0 or newer.
  • Objects passed to decorated functions must be pickleable (dill is used for serialization).

License · maintenance · safety

MIT (permissive) — MIT license is permissive with no restrictions on commercial or private use. You may use, modify, and distribute this package freely provided you include the license notice.

last release 2024-02-28 (898 days) · last repo commit 2026-04-24 · 164 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 2,198,074 downloads/mo, #3,216 on PyPI

Verify before relying

from wrapt_timeout_decorator import timeout
import time

@timeout(5)
def example():
    time.sleep(10)

if __name__ == '__main__':
    example()
  • Whether the package handles timeout exceptions consistently across all Python versions it claims to support (3.8–3.12, PyPy 3.9–3.10).
  • Performance overhead of subprocess spawning on repeated decorator invocations in tight loops.
  • Compatibility with async/await and asyncio event loops beyond the mentioned FastAPI/Uvicorn considerations.
Same gist for agents: .md · .json

What it is and what it does

wrapt_timeout_decorator is a decorator library that enforces time limits on function execution in Python. It addresses the common problem of functions that may hang indefinitely by wrapping them with a timeout mechanism. Unlike simpler timeout decorators, this package handles edge cases correctly: it works with class methods, static methods, instance methods, and preserves traceback information for debugging in tools like PyCharm.

The package offers two timeout strategies. On POSIX systems (Linux, macOS), it can use signals for elegant, efficient timeouts, but with caveats documented in the project. By default and on Windows, it uses subprocesses to enforce timeouts, which requires that decorated function arguments and return values be serializable via dill. The timeout value can be static, dynamically calculated, or adjusted via an optional eval function. It depends on wrapt, multiprocess, dill, psutil, and utility packages for subprocess management and test-environment detection.

Use it for

  • Wrap database queries or network calls that may hang, ensuring they fail fast with a timeout exception rather than blocking indefinitely.
  • Protect long-running file I/O or data processing operations in batch jobs, applying a timeout at the function level to prevent resource exhaustion.
  • Enforce time limits on third-party library calls where the library itself offers no timeout parameter, as a last resort after exhausting built-in options.
  • Handle Windows compatibility for timeout-protected code by automatically falling back to subprocess strategy when signals are unavailable.
  • Debug hanging functions in PyCharm by preserving full traceback information through the timeout mechanism.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

With conditions

Yes, if you need a robust timeout decorator that handles methods and classes correctly and works cross-platform.

The package is actively maintained, has no known vulnerabilities, and low install friction. However, reserve it as a last resort after checking whether the libraries you're calling already offer native timeout support; the subprocess overhead on Windows and repeated invocations can be significant. Ensure your decorated function arguments are pickleable.

Install

wrapt-timeout-decorator on PyPI

Before you install

Low friction install with a pure-Python wheel. Maintenance is active with recent commits and stable production status. Six runtime dependencies (wrapt, multiprocess, dill, psutil, lib-detect-testenv, cli-exit-tools) are all standard libraries or well-maintained packages, posing no unusual risk.

On Windows, subprocess strategy is the only option (signals unavailable); on POSIX systems, signals cannot be used within subthreads. Requires Python 3.8.0 or newer. Objects passed to decorated functions must be pickleable (dill is used for serialization).

License in practice

MIT license is permissive with no restrictions on commercial or private use. You may use, modify, and distribute this package freely provided you include the license notice.

Quickstart

from wrapt_timeout_decorator import timeout
import time

@timeout(5)
def example():
    time.sleep(10)

if __name__ == '__main__':
    example()

Verify before relying

  • Whether the package handles timeout exceptions consistently across all Python versions it claims to support (3.8–3.12, PyPy 3.9–3.10).
  • Performance overhead of subprocess spawning on repeated decorator invocations in tight loops.
  • Compatibility with async/await and asyncio event loops beyond the mentioned FastAPI/Uvicorn considerations.

Package facts

LicenseMIT permissive
Python supportSupports the current Python release >=3.8.0
Install frictionLow. Pure-Python wheel
Runtime dependencies
6 packages
cli-exit-toolslib-detect-testenvmultiprocesspsutilwraptdill
MaintenanceActively maintained 898 days since the last release
Last repo commit
First released
Downloads2,198,074 / month, #3,216 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonTopic :: Software Development :: Libraries :: Python Modules

Evidence: wrapt_timeout_decorator-1.5.1-py3-none-any.whl

Tags

Capabilities
timeout decorator pythonfunction timeout limittimeout with subprocesssignal-based timeouttimeout for methods and classescross-platform timeouttimeout exception handler
Topics
timeout-enforcementcross-platformdecorator-pattern

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “timeout for methods and classes”

Give your agent the search over MCP, or paste the wish link into any chat.

More Python Modules packages

idna Worth it
PyPI · Python Modules · released Jun 2026

Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.

Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.

BSD-3-Clausepure Python · 3.9+
1.8Bdownloads / mo
setuptools Worth it
PyPI · Python Modules · released Aug 2026

Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.

MITpure Python · 3.10+
1.6Bdownloads / mo
PyYAML Worth it
PyPI · Python Modules · released Sep 2025

PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.

MITcompiled wheel · 3.8+
1.2Bdownloads / mo
pydantic Worth it
PyPI · Python Modules · released May 2026

Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.

MITpure Python · 3.9+
1.1Bdownloads / mo
annotated-types Worth it
PyPI · Python Modules · released Jul 2026

Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.

Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…

MITpure Python · 3.10+
871.3Mdownloads / mo
typing-inspection Worth it
PyPI · Python Modules · released Aug 2026

Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.

MITpure Python · 3.10+
783.0Mdownloads / mo

See also timeout-decorator · interruptingcow · cli-exit-tools · retry-decorator · stopit · pytest-timeout · EasyProcess · func-timeout · wrapt · pytest-timeouts