Skip to content

Distributed across workers

The controller and its workers, which see completely different runs.

Run under pytest-xdist, a session is several processes, and they do not see the same thing at all. The process you launched - the controller - never collects a test and never runs one. It starts workers, hands out work, and receives results. Each worker collects the entire suite for itself, then runs whatever it was given.

That is why this page has a diagram per process rather than one. The controller reaches around 25 hooks, a worker around 41, and the overlap between them is small.

The scheduler changes what you see, so the command is printed with every diagram below. This capture uses --dist each, which gives every worker the whole suite: the workers are then identical, and the page draws them once. Under a splitting scheduler - loadfile, loadscope, load, worksteal - workers differ by the tests they happened to draw, and this page would show one section per distinct worker flow. The controller differs too: those four modes all produce one controller flow, and each produces another.

This scenario also reaches the last two hooks pytest declares but never calls itself: pytest_report_to_serializable in the workers, where a result is packed up to be sent, and pytest_report_from_serializable in the controller, where it is unpacked. And it brings twelve hooks of xdist's own, which pytest knows nothing about - they are described here because hookspecs are read from the running plugin manager rather than from pytest's source.

Latest pytest - or pick a flow below.

Distinct flows

40 captured releases produce 7 distinct flows.

Captured from pytest 7.0.0 onward rather than from the oldest release on the site: this scenario needs pytest >=7.0, because pytest-xdist==3.8.0 does. Earlier releases are not missing - they are outside what this scenario can run against.

Flow Releases
pytest 9.1.0 - 9.1.1 2
pytest 8.2.0 - 9.0.3 16
pytest 8.1.1 - 8.1.2 2
pytest 8.0.0 - 8.0.2 3
pytest 7.3.2 - 7.4.4 6
pytest 7.1.0 - 7.3.1 9
pytest 7.0.0 - 7.0.1 2