I Replaced pytest-xdist With 60 Lines of subprocess.Popen. Here's Why.

TL;DR AI
2 min readKey summary
A flaky Python test suite was traced to shared state leaking across pytest-xdist workers.
The team replaced xdist with a launcher that starts one fresh Python process per test file using subprocess.Popen and bounded parallelism.
This kept runtime manageable while eliminating cross-file leakage and stabilizing CI.
The article also stresses killing entire subprocess trees on timeout to avoid orphaned grandchildren.
