{"categories":[{"label":"Python Modules","url":"https://skillfed.io/packages/category/software-development-libraries-python-modules/6"}],"enrichment":{"capability":"Applies timeout limits to Python functions and methods via decorator, with support for both signal-based (POSIX) and subprocess-based (cross-platform) strategies, preserving tracebacks and handling classes, methods, and static methods correctly.","skillfed_tags":["timeout-enforcement","cross-platform","decorator-pattern"],"use_cases":["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."],"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.\n\nThe 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.","worth_installing":"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."},"id":"wrapt-timeout-decorator","links":{"html":"https://skillfed.io/packages/wrapt-timeout-decorator","md":"https://skillfed.io/packages/wrapt-timeout-decorator.md","pypi":"https://pypi.org/project/wrapt-timeout-decorator/"},"maintenance":{"status":"active"},"meta":{"latest_release":"2024-02-28","license_spdx":null,"license_treatment":"permissive","name":"wrapt-timeout-decorator","python_support":"supports_current","summary":"The better timout decorator"},"popularity":{"monthly_downloads":2198074,"position":3216,"tier":"top_5000"},"security":{"n_vulnerabilities":0},"version":"1.5.1"}
