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
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.
解决方案
-
80% 成功率 Reduce the number of workers to match the number of available CPU cores.
pytest -n 4 (where 4 is the number of cores)
-
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
无效尝试
常见但无效的做法:
-
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.
-
Setting a global timeout for all tests
70% 失败
Timeout may abort tests prematurely without addressing the scheduling issue.