pytest-xdist "worker crashed" in CI
A pytest-xdist worker process died mid-run - usually killed by the OS for memory, or crashed by a native extension/segfault. xdist reports the worker and the test it was running when it crashed.
What this error means
pytest-xdist reports "[gw0] node down: Not properly terminated" or "worker 'gw0' crashed while running '<test>'", and the run aborts or replays the test.
[gw1] node down: Not properly terminated
replacing crashed worker gw1
worker 'gw1' crashed while running 'tests/test_heavy.py::test_big_matrix'Common causes
Out-of-memory under parallelism
Running many workers multiplies memory; a heavy test pushes a worker past the runner's RAM and the OS kills it.
A native crash or segfault in a worker
A C-extension fault, a hung subprocess, or a shared-state bug terminates the worker abnormally.
How to fix it
Reduce parallelism or isolate the test
- Lower the worker count so memory per worker is sufficient.
- Isolate or serialize the heavy/crashing test.
- Re-run to confirm the worker no longer dies.
pytest -n 2 --dist loadscopeRight-size the runner for the workload
Give the job a larger runner so concurrent workers have enough memory.
runs-on: ubuntu-latest-8-coresHow to prevent it
- Match worker count to the runner's memory budget.
- Quarantine tests that segfault native extensions.
- Use
--dist loadscopeto keep related tests on one worker.