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
test_thread should clean threads after each test #74542
Comments
http://buildbot.python.org/all/builders/AMD64%20Debian%20root%202.7/builds/154/steps/test/logs/stdio 0:04:59 [312/402/1] test_thread failed
Traceback (most recent call last):
File "/root/buildarea/2.7.angelico-debian-amd64/build/Lib/test/test_thread.py", line 133, in task
raise SyntaxError
SyntaxError: None
test test_thread failed -- Traceback (most recent call last):
File "/root/buildarea/2.7.angelico-debian-amd64/build/Lib/test/test_thread.py", line 150, in test_save_exception_state_on_error
self.assertIn("Traceback", stderr.getvalue())
AssertionError: 'Traceback' not found in 'Unhandled exception in thread started by <function task at 0x7f06c77ab1b0>\n' |
I just encountered with this failure. It is random, I can reproduce it only when run test_thread repeatedly in parallel with running other tests (maybe needed high load factor). $ ./python -m test -uall -F test_thread test_thread test_thread test_thread
Run tests sequentially
0:00:00 [ 1] test_thread
0:00:00 [ 2] test_thread
Traceback (most recent call last):
File "/home/serhiy/py/cpython2.7/Lib/test/test_thread.py", line 133, in task
raise SyntaxError
SyntaxError: None
test test_thread failed -- Traceback (most recent call last):
File "/home/serhiy/py/cpython2.7/Lib/test/test_thread.py", line 150, in test_save_exception_state_on_error
self.assertIn("Traceback", stderr.getvalue())
AssertionError: 'Traceback' not found in 'Unhandled exception in thread started by <function task at 0xb6a89ee4>\n' 1 test OK. Total duration: 432 ms |
Problem is with test test_thread.ThreadRunningTests.test_save_exception_state_on_error when other tests leave threads runnig. test_save_exception_state_on_error relay on thread._get_count(), if this value decrease test assume thread is finished with is not always correct (other threads finish - started by different test). Fix is to make sure each test wait for all threads to finsh. |
The solution in PR 1583 looks unsafe to me. If some threads hang the loop |
Using 5 terminals to run 5 tests in parallel. I'm unable to reproduce the bug if I only run the test alone: ./python -m test -uall -F -m test_save_exception_state_on_error test_thread But I'm able to reproduce the bug if I run the full test_thread.py: ./python -m test -uall -F test_thread So I'm now more confident that grzgrzgrz3's patch can fix the issue. test_thread uses the low-level thread.start_new_thread() function to spawn threads, but pthread_join() is not used to wait for the thread exit. So multiple test_thread tests can "leak" threads which can have random effect on following tests. |
I think this do not solve this issue yet. There is still posibillity that different tests/testrunners spawn threads and 'fool' testcase. I think we should not relay on For master branch I would like to know your opinion it is worth changing? |
There is still posibillity that different tests/testrunners spawn threads If you run multiple test files in parallel, each test runner process runs a |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: