Skip to content

Environment variable to specify number of workers for "auto" #792

@encukou

Description

@encukou

Would you accept a PR to read an environment variable when determining what -n auto means?

Concrete use case:
We're trying to make testing easier in Fedora RPM builds, where one should ideally use a somewhat obscure macro (%{_smp_build_ncpus}) for the best number of processes on a builder machine, but many packagers simply reuse upstream projects' command lines, with -n auto. It would be nice if we could set e.g. PYTEST_XDIST_AUTO_NUM_WORKERS in our default pytest environment, and document -n auto as best practice for pytest-xdist.
Doing this in the plugin hook (pytest_xdist_auto_num_workers) would probably be possible, but very cumbersome compared to an environment variable.
I assume there are other use cases where this would be useful.

I'm thinking the pytest_xdist_auto_num_workers hook should have priority if both it and the env var are specified: for having it the other way. it's fairly easy to check the env var from a plugin.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions