Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support starting only once with xdist #144

Open
FRidh opened this issue Jan 17, 2024 · 1 comment
Open

Support starting only once with xdist #144

FRidh opened this issue Jan 17, 2024 · 1 comment

Comments

@FRidh
Copy link

FRidh commented Jan 17, 2024

Is your feature request related to a problem? Please describe.
It is not uncommon wanting to start and stop a global service during a pytest run. Often test runs are also parallelized using pytest-xdist.

Describe the solution you'd like
Possibility to start a process when the fixture is first needed, and destruct when the fixture is not in use anymore at all. Both with single worker and multiple (local) workers.

Describe alternatives you've considered
Using https://pytest-xdist.readthedocs.io/en/stable/how-to.html#xdist.is_xdist_master separately or together for this purpose does not seem to work.

An alternative is another entry point that then starts pytest.

Additional context
Add any other context or screenshots about the feature request here.

@northernSage
Copy link
Member

Hey @FRidh, I think you can probably go for something like https://pytest-xdist.readthedocs.io/en/stable/how-to.html#making-session-scoped-fixtures-execute-only-once

just watch out for how you are cleaning up (xprocess.terminate call), you can use somthing along the lines of the link above with lock files to ensure all workers exist before terminating the process

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants