# pytest.xdist.WorkerInterrupted: worker 'gw0' crashed or timed out after 300 seconds

- **ID:** `python/pytest-xdist-worker-timeout`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A test worker in pytest-xdist took longer than the specified timeout (default 300s) to complete, often due to a hanging test, infinite loop, or slow external resource.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.0.0 | active | — | — |
| 3.1.0 | active | — | — |

## Workarounds

1. **Set a longer timeout for specific tests using pytest.mark.timeout or xdist's --timeout option** (75% success)
   ```
   pip install pytest-timeout
@pytest.mark.timeout(600)
def test_slow_operation():
    ...
Or run: pytest --timeout=600 -n auto
   ```
2. **Identify and fix the hanging test by running it in isolation with verbose logging** (90% success)
   ```
   Run the test individually: pytest tests/test_slow.py -v --timeout=60
Add logging to identify where it hangs, then fix the infinite loop or resource issue.
   ```

## Dead Ends

- **Increasing the timeout limit globally without investigating the root cause** — This only delays the failure; the underlying issue (e.g., a hanging test) remains and may cause intermittent failures. (70% fail)
- **Disabling xdist entirely to avoid the timeout** — This removes parallel execution benefits, slowing down the test suite significantly. (40% fail)
