func-timeout
Python module which allows you to specify timeouts when calling any existing function. Also provides support for stoppable-threads
Decision gist · record as of 2026-08-14
Yes, with conditions. Install if you need timeout protection for function calls and can accept dormant maintenance (last release 2019). The package is stable, has no known vulnerabilities, and solves a real problem with minimal dependencies. Avoid if you require active support or need guaranteed compatibility with Python versions beyond 3.7, or if you prefer a maintained alternative. High install friction (source-only) is a minor friction point.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 2.7 or 3.4+; uses threading and may have platform-specific behavior around exception injection into C code.
- High install friction due to source-only distribution (tar.gz).
- Maintenance is dormant—last release was 2019-08-19, over six years ago, though the repository remains active with recent commits.
License · maintenance · safety
LGPLv2 (copyleft) — Licensed under LGPLv2 (copyleft). Any derivative work or modification must be released under the same license; linking in a proprietary application requires careful review of your license obligations.
last release 2019-08-19 (2552 days) · last repo commit 2024-03-01 · 328 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 7,584,368 downloads/mo, #1,719 on PyPI
Alternatives
Verify before relying
from func_timeout import func_timeout, FunctionTimedOut
try:
result = func_timeout(5, my_function, args=('arg1', 'arg2'))
except FunctionTimedOut:
print('Function exceeded 5 second timeout')- Whether the package works reliably on modern Python versions (3.8+) despite classifiers only listing up to 3.7.
- Performance impact of the polling mechanism (raises exception every 2 seconds) on CPU-bound workloads.
- Behavior when timing out functions that hold locks or interact with external resources.
What it is and what it does
func_timeout wraps function calls in a timeout mechanism by running them in a separate thread and raising FunctionTimedOut if execution exceeds a specified duration. It returns the function's result or re-raises any exception it would normally throw. The package also includes a decorator form (@func_set_timeout) for cleaner syntax and a StoppableThread class that extends threading.Thread to support forceful termination via exception injection into the thread context.
The core use case is protecting against indefinite hangs in code you call but cannot control—network requests, file I/O, or third-party library calls that may block. Timeouts can be fixed values or computed dynamically based on function arguments. The FunctionTimedOut exception includes a retry() method to re-attempt the call with different timeout settings.
Use it for
- Wrap external API calls or network requests to prevent indefinite blocking when servers hang or are unresponsive.
- Enforce maximum execution time on user-submitted or untrusted code in a sandbox or job queue.
- Decorate long-running data processing functions to fail fast if they exceed expected runtime.
- Implement graceful shutdown of worker threads in an event loop or thread pool by stopping them with a custom exception.
- Protect against infinite loops or deadlocks in third-party library code by terminating after a timeout.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, with conditions.
Install if you need timeout protection for function calls and can accept dormant maintenance (last release 2019). The package is stable, has no known vulnerabilities, and solves a real problem with minimal dependencies. Avoid if you require active support or need guaranteed compatibility with Python versions beyond 3.7, or if you prefer a maintained alternative. High install friction (source-only) is a minor friction point.
Install
func-timeout on PyPI
Before you install
High install friction due to source-only distribution (tar.gz). Maintenance is dormant—last release was 2019-08-19, over six years ago, though the repository remains active with recent commits. Production-stable status and no known vulnerabilities suggest the code is stable, but no active development or support.
Requires Python 2.7 or 3.4+; uses threading and may have platform-specific behavior around exception injection into C code.
License in practice
Licensed under LGPLv2 (copyleft). Any derivative work or modification must be released under the same license; linking in a proprietary application requires careful review of your license obligations.
Quickstart
from func_timeout import func_timeout, FunctionTimedOut
try:
result = func_timeout(5, my_function, args=('arg1', 'arg2'))
except FunctionTimedOut:
print('Function exceeded 5 second timeout')
Verify before relying
- Whether the package works reliably on modern Python versions (3.8+) despite classifiers only listing up to 3.7.
- Performance impact of the polling mechanism (raises exception every 2 seconds) on CPU-bound workloads.
- Behavior when timing out functions that hold locks or interact with external resources.
Package facts
| License | LGPLv2 copyleft |
| Python support | Not specified |
| Install friction | High. Source build required |
| Runtime dependencies | None |
| Maintenance | Dormant 2,552 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 7,584,368 / month, #1,719 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableLicense :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)Programming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Topic :: Software Development :: Libraries :: Python Modules |
Evidence: func_timeout-4.3.5.tar.gz
Tags
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 › “call function with timeout”
- func-timeoutRuns any Python function with a specified timeout limit, raising an…
- timeout-samplerPolls a function repeatedly within a timeout window, collecting…
- django-cache-memoizeA decorator that caches function results using Django's cache…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
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.
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.
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.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
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…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also kthread · stopit · timeout-sampler · threaded · timeout-decorator · retry2 · pytest-timeout · retry · async-timeout · python-backoff