Skip to content

Twins that start their own fixture servers collide under pytest -n: pick_port gives every xdist worker the same port #1742

Closed

Description

@jdatcmd

Three reviews found the same race independently:

CI runs the cluster files serially, so CI is green. But the guard job runs with -n 4, a developer running -n gets false reds, and #1740 notes that moving the cluster job to xdist (to cut its 17-minute run) waits on this.

Why: a module fixture that starts an S3/HTTP fixture server picks its port with pick_port(base), which does not depend on the xdist worker. Two workers probe the same free port at the same moment and both bind it (or one fails with Address already in use).

Next step: a guard that runs one such twin under -n 2 and requires green, red first; then make the port depend on the worker (as pgc_cluster does for its own clusters), or bind port 0 and read back the port.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions