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

Only test register_handler in a single thread #8501

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

radarhere
Copy link
Member

@radarhere radarhere commented Oct 26, 2024

Possible way to help #8492. Alternative to #8518

The issue has found that running a test that calls register_handler at the beginning, and removes the handler at the end, fails when the test is run across multiple threads.

My thinking is that if it ok for register_handler to operate across threads, and that it doesn't need to register multiple handlers in parallel. So this PR returns early from the relevant test if it is already running in another thread.

Copy link
Contributor

@lysnikolaou lysnikolaou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also been working on fixing some of these issues. Since you think we should leave these alone in #8492 (comment), I think we should mark the tests with @pytest.mark.parallel_threads(1) instead.

@radarhere
Copy link
Member Author

Is it a problem that pytest.mark.parallel_threads would only work for pytest-run-parallel? We've also had #8454 from a person using https://github.com/tonybaloney/pytest-freethreaded. If that happens again, do we need to ask such a user to change testing tools?

#8518 is another idea I had.

@lysnikolaou
Copy link
Contributor

Is it a problem that pytest.mark.parallel_threads would only work for pytest-run-parallel? We've also had #8454 from a person using tonybaloney/pytest-freethreaded. If that happens again, do we need to ask such a user to change testing tools?

I'm not sure about that to be honest. I'm using pytest-run-parallel cause I like the fact that the default is a single thread. The best solution here would be to have a @pytest.mark.thread_unsafe mark that would work across plugins. I can coordinate doing that.

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

Successfully merging this pull request may close these issues.

2 participants