python system_error ai_generated partial

pytest.xdist.NoWorkerIdle:没有空闲工作节点可用于测试调度

pytest.xdist.NoWorkerIdle: No idle worker available for test scheduling

ID: python/pytest-xdist-no-worker-idle

其他格式: JSON · Markdown 中文 · English
80%修复率
80%置信度
0证据数
2024-11-01首次发现

版本兼容性

版本状态引入弃用备注
3.9 active
3.10 active

根因分析

所有工作进程都在处理长时间运行的测试,并且在超时时间内没有工作节点空闲。

English

All worker processes are busy with long-running tests, and no worker becomes free within the timeout period.

generic

解决方案

  1. 80% 成功率 Reduce the number of workers to match the number of available CPU cores.
    pytest -n 4 (where 4 is the number of cores)
  2. 85% 成功率 Run long-running tests sequentially by marking them with @pytest.mark.slow and using -m 'not slow'.
    pytest -m 'not slow' -n auto; then run slow tests separately with -n 1

无效尝试

常见但无效的做法:

  1. Increasing the number of workers to speed up tests 60% 失败

    If tests are long, more workers may not help if the bottleneck is I/O or CPU.

  2. Setting a global timeout for all tests 70% 失败

    Timeout may abort tests prematurely without addressing the scheduling issue.