Skip to content

bpo-30357 each test in test_thread waits until all spawned threads finish #1583

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

Merged
merged 4 commits into from
May 15, 2017

Conversation

grzgrzgrz3
Copy link
Contributor

No description provided.

@@ -32,6 +32,11 @@ def setUp(self):
self.created = 0
self.running = 0
self.next_ident = 0
self.thread_count = thread._count()

def tearDown(self):
Copy link
Member

Choose a reason for hiding this comment

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

This code looks similar to threading_cleanup(): please use threading_setup() and threading_cleanup() from test.support.

@vstinner
Copy link
Member

LGTM, but I would prefer to fix experiment this change in the master branch, before touching the super-stable 2.7 branch. Can you propose the same change for the master branch please?

@grzgrzgrz3
Copy link
Contributor Author

I was unable to reproduce this issue on the master branch. However still it's worth to clean up tests correctly. I will create new PR for master branch.

What you think about rewriting test_save_exception_state_on_error and use _thread._set_sentinel instead thread._count?

@vstinner
Copy link
Member

You also need to add yourself to Misc/ACKS. You might also document the change in Misc/NEWS. I created #1592 for master where I credited you ;-)

@vstinner
Copy link
Member

I was unable to reproduce this issue on the master branch. However still it's worth to clean up tests correctly.

Well, we are talking about race conditions. It's really hard to reproduce them. It's likely that the test order changed between Python 2.7 and master, but it doesn't mean that master is bugfix. Just that the bug is less likely :-)

I will create new PR for master branch.

Sorry, I wanted to fix quickly the bug, so I pushed a fix based on your work on the master branch and added your name ;-) Can you please try to backport the fix to 2.7? Try to cherry-pick the change from master (or complete this change).

grzgrzgrz3 and others added 2 commits May 15, 2017 18:36
test_thread: setUp() now uses support.threading_setup() and
support.threading_cleanup() to wait until threads complete to avoid
random side effects on following tests.

Co-Authored-By: Victor Stinner <[email protected]>
test_thread: setUp() now uses support.threading_setup() and
support.threading_cleanup() to wait until threads complete to avoid
random side effects on following tests.

Co-Authored-By: Victor Stinner <[email protected]>
@vstinner vstinner merged commit 6924ed5 into python:2.7 May 15, 2017
@vstinner
Copy link
Member

LGTM! Thanks for the backport.

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

Successfully merging this pull request may close these issues.

3 participants