pytest-timeout
pytest plugin to abort hanging tests
Decision gist · record as of 2026-08-14
Yes. This is a mature, actively maintained plugin (Production/Stable status, last release 2025-05-05) with no known vulnerabilities and low install friction. It solves a real problem—detecting hanging tests in CI—and is widely used (top 1000 PyPI packages). Install it if you run tests in environments where manual intervention is impractical; skip it if your test suite is already fast and you have other mechanisms to catch hangs.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Timeout termination method (signal vs.
- thread) is platform-dependent; signal method may interfere with code under test that uses SIGALRM, and thread method will skip teardown and JUnit XML output.
- Low friction—a pure Python wheel with only pytest as a runtime dependency.
License · maintenance · safety
MIT (permissive) — MIT license (permissive); you can use, modify, and distribute this plugin freely in commercial and private projects with minimal restrictions.
last release 2025-05-05 (466 days) · last repo commit 2026-06-30 · 255 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 103,142,767 downloads/mo, #334 on PyPI
Alternatives
Verify before relying
pip install pytest-timeout
# In your test file:
import pytest
@pytest.mark.timeout(60)
def test_foo():
pass
# Or run with a global timeout:
# pytest --timeout=300- Whether the plugin's overhead is acceptable for test suites with many short tests.
- Compatibility with specific test frameworks or fixtures beyond pytest's standard model.
What it is and what it does
pytest-timeout is a pytest plugin that enforces time limits on individual tests to catch hanging or deadlocked tests. It terminates tests that exceed a configured duration and dumps the stack of all running threads to stderr for debugging. The plugin supports both a global timeout (set via command line, environment variable, or config file) and per-test overrides using the @pytest.mark.timeout decorator.
The plugin offers two termination methods: signal (graceful on POSIX, allows test run to continue) and thread (more portable, terminates the whole process). The signal method is the default on systems that support SIGALRM; thread is the fallback. The documentation explicitly warns that this is a last-resort tool for catching excessively long test durations, not a replacement for writing fast tests or measuring performance regressions.
Use it for
- Catch deadlocked or hanging tests in continuous integration pipelines where manual intervention is not possible.
- Debug test suite hangs by examining stack dumps of all threads printed to stderr when a timeout fires.
- Set per-test timeouts for known slow operations while maintaining a global timeout for the rest of the suite.
- Prevent a single hanging test from blocking the entire test run in CI environments.
- Identify tests that have become unexpectedly slow due to code changes or environment issues.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
This is a mature, actively maintained plugin (Production/Stable status, last release 2025-05-05) with no known vulnerabilities and low install friction. It solves a real problem—detecting hanging tests in CI—and is widely used (top 1000 PyPI packages). Install it if you run tests in environments where manual intervention is impractical; skip it if your test suite is already fast and you have other mechanisms to catch hangs.
Install
pytest-timeout on PyPI
Before you install
Low friction—a pure Python wheel with only pytest as a runtime dependency. Actively maintained with recent releases; last commit 2026-06-30 and 255 GitHub stars indicate steady use.
Timeout termination method (signal vs. thread) is platform-dependent; signal method may interfere with code under test that uses SIGALRM, and thread method will skip teardown and JUnit XML output.
License in practice
MIT license (permissive); you can use, modify, and distribute this plugin freely in commercial and private projects with minimal restrictions.
Quickstart
pip install pytest-timeout
# In your test file:
import pytest
@pytest.mark.timeout(60)
def test_foo():
pass
# Or run with a global timeout:
# pytest --timeout=300
Verify before relying
- Whether the plugin's overhead is acceptable for test suites with many short tests.
- Compatibility with specific test frameworks or fixtures beyond pytest's standard model.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.7 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagepytest |
| Maintenance | Actively maintained 466 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 103,142,767 / month, #334 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/StableEnvironment :: ConsoleEnvironment :: PluginsFramework :: PytestIntended Audience :: DevelopersLicense :: DFSG approvedLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Testing |
Evidence: pytest_timeout-2.4.0-py3-none-any.whl
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 › “abort hanging tests”
- pytest-timeoutAborts pytest tests that exceed a specified time limit, with stack…
- pytest-operatorA pytest plugin that provides fixtures and helpers for writing…
- transactionProvides a generic transaction management system for Python, handling…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.
Install it if you write tests for any asyncio-based code.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
See also pytest-fail-slow · pytest-socket · pytest-timeouts · stopit · interruptingcow · pytest-run-parallel · func-timeout · pytest_tagging · pytest-extra-durations · wrapt-timeout-decorator