Only test `register_handler` in a single thread
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.
Is it a problem that pytest.mark.parallel_threads would only work for pytest-run-parallel? We've also had https://github.com/python-pillow/Pillow/issues/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?
https://github.com/python-pillow/Pillow/pull/8518 is another idea I had.
Is it a problem that
pytest.mark.parallel_threadswould only work forpytest-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.