python runtime_error ai_generated partial

Failed: Timeout >300.0s pytest-timeout: test_heavy_import timed out after 300 seconds

ID: python/pytest-timeout-test-exceeded

Also available as: JSON · Markdown · 中文
80%Fix Rate
84%Confidence
0Evidence
2024-12-03First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active — — —

Root Cause

A test exceeded the configured timeout (global or per-test). Often caused by a blocking network call, an unclosed DB transaction waiting on a lock, or a subprocess that never terminates.

generic

中文

测试超过了配置的超时时间(全局或单测试)。通常由阻塞的网络调用、等待锁的未关闭数据库事务,或永不终止的子进程引起。

Workarounds

  1. 90% success
    # pyproject.toml
    [tool.pytest.ini_options]
    addopts = "--timeout=60 --timeout-method=signal"
    
    # per-test
    @pytest.mark.timeout(10)
    def test_api():
        ...
  2. 85% success
    pytest -o faulthandler_timeout=30 tests/test_heavy_import.py -s
    # or run with py-spy
    py-spy dump --pid <pid>

Dead Ends

Common approaches that don't work:

  1. 70% fail

    Hides the real hang; CI now waits an hour per stuck test, and the underlying deadlock persists.

  2. 80% fail

    CI will hang indefinitely on the same test, blocking the whole pipeline.