-
Notifications
You must be signed in to change notification settings - Fork 234
pytest-xdist causes warnings to be emitted when a unit test uses os.fork() #1186
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
Comments
Recent xdist+execnet has a workaround to ensure xdist runs on the main thread |
This is a longstanding issue with execnet The introduction of execmodels made it possible for pytest to run on non main threads |
why is the thread not showing in |
seems its using the lowlevel primitive |
that's what I thought though I didnt know you could do that from pure python. OK! I think I might have even known about this issue at some point so I'm going to note this , thanks |
i think we should definitively use the high-level ones instead as debugging those is a pain |
i wonder if there was a specific technical reason for how it ended up with lowlevel primitives for threads |
We're using the latest versions of pytest and pytest-xdist but we're still seeing this warning ... and we are occasionally seeing our builds hang. Is this supposed to be resolved?
|
With the latest versions of xdist and execnet we should be running on the main thread I realized that for xdist and execnet we should strongly recommend spawn instead of fork |
How do we configure spawn vs fork? |
we learned that theres no god reason for execnet to use the lowlevel primitives - pytest-dev/execnet#336 is a experiment to use the high level ones again |
Sorry I misunderstood - I got the impression there was some way in pytest-xdist to configure how it handled creating new threads... |
test suite:
Running as
pytest test.py -n1
, output:Per the author of this warning, multithreaded code is never safe if it also spawns using fork (see discussion). However I cannot locate any threads running. Here's an extension of the example that lists out threads running, and I can find none that are not the "main" thread:
conftest.py:
test.py:
run output:
Basically I want to keep using fork() in my test code, since we are running functions inside the tests themselves in processes. Where is pytest-xdist and/or execnet spawning threads exactly (code is pretty opaque) and is this a bug in the python interpreter?
The text was updated successfully, but these errors were encountered: