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

Question: Is it expected, that the tests run in the main thread? #469

Open
mchlnix opened this issue Sep 19, 2019 · 7 comments
Open

Question: Is it expected, that the tests run in the main thread? #469

mchlnix opened this issue Sep 19, 2019 · 7 comments

Comments

@mchlnix
Copy link

mchlnix commented Sep 19, 2019

I have some code that registers signals, basically starting it's own thread.

This needs to be in the main thread, since signals only work there. Once every, maybe, 30 executions in my CI an assert triggers, that my code (and thereby the test) was not executed on the main thread.

Is there a way to reliably make that happen? How come this is so rare? Could the CI and maybe hyperthreading have something to do with it?

@chrahunt
Copy link

chrahunt commented Nov 8, 2019

Can you provide any more information to reproduce this? What version of xdist are you using? What options?

@RonnyPfannschmidt
Copy link
Member

That issue got introduced when execnet got thread models I believe, I suggest trying older versions of execnet

@symonk
Copy link
Member

symonk commented Dec 3, 2019

I know the problem you are facing, occasionally a worker comes online with both MainThread and _DummyThread, I learned this the hard way using interrupting-cow, we just rolled our own slightly worse solution and everything works as normal

@kimyen
Copy link

kimyen commented Apr 23, 2020

I got the same problem. My tests are expected to be run in main thread. I'm exploring solution here. Would using pytest-ordering ensures that tests are run in main thread? I assume that it ensures the order and therefore run tests sequentially. Hence, there is no need to bring up new threads.

@RonnyPfannschmidt
Copy link
Member

@kimyen the issue is that modern execnet no longer guarantees that certain code runs in the main thread, and thus it creates a problem for such test

@kimyen
Copy link

kimyen commented Apr 23, 2020

@RonnyPfannschmidt , do you suggest any workaround for this problem? Or if there is a version of pytest-xdist that doesn't have this problem? Or which version of execnet has this problem? We do have any direct dependency on execnet, but maybe pytest-xdist should specifies a fix version to execnet.

@zmedico
Copy link
Contributor

zmedico commented Feb 15, 2024

This looks the same as #620 which was opened later but has had more attention. Also see pytest-dev/execnet#96.

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

No branches or pull requests

6 participants