python
runtime_error
ai_generated
true
Failed: Timeout (>60.0s) from pytest-timeout.
ID: python/pytest-timeout-hung-test
80%Fix Rate
86%Confidence
0Evidence
2024-07-08First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 2.x | active | — | — | — |
Root Cause
A test blocked on network I/O, an unclosed socket, a deadlock, or an infinite loop; pytest-timeout killed it after the configured threshold.
generic中文
测试阻塞在网络 I/O、未关闭的套接字、死锁或无限循环上;pytest-timeout 在配置的阈值后终止了它。
Workarounds
-
90% success
pytest --timeout=60 --timeout-method=thread -o faulthandler_timeout=55 tests/test_net.py
-
95% success
from unittest import mock @mock.patch('app.client.requests.get') def test_fetch(mock_get): mock_get.return_value.json.return_value = {"ok": True} ... -
88% success
@pytest.mark.timeout(5) def test_quick(): ...
Dead Ends
Common approaches that don't work:
-
85% fail
Extends CI time without fixing the underlying hang.
-
95% fail
CI hangs indefinitely; hides the bug.
-
90% fail
A hang is not flakiness.