python
runtime_error
ai_generated
true
Failed: Timeout (>60.0s) from pytest-timeout.
ID: python/pytest-timeout-exceeded-hanging-test
80%Fix Rate
86%Confidence
0Evidence
2024-08-30First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 2.2.x | active | — | — | — |
| 2.3.x | active | — | — | — |
Root Cause
A test or fixture blocked longer than the configured timeout — often due to a network call without timeout, an unclosed DB connection, or a deadlock in a threaded fixture.
generic中文
测试或 fixture 阻塞时间超过配置的超时——常见原因是无超时的网络调用、未关闭的数据库连接,或线程 fixture 中的死锁。
Workarounds
-
90% success
import httpx r = httpx.get(url, timeout=5.0) # or requests requests.get(url, timeout=(3.05, 5))
-
85% success
# pytest.ini [pytest] timeout = 30 timeout_method = signal # per test @pytest.mark.timeout(10) def test_fast(): ...
Dead Ends
Common approaches that don't work:
-
75% fail
Masks the hang; CI still stalls and the underlying deadlock remains, eventually failing at a higher timeout.
-
55% fail
Thread method can't interrupt blocking C calls (e.g., socket recv); the test still hangs and gets killed at signal level.