Skip to content

bpo-31234: Try to fix lock_tests warning #3557

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 1 commit into from
Sep 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Lib/test/lock_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ def wait_for_started(self):
def wait_for_finished(self):
while len(self.finished) < self.n:
_wait()
# Wait a little bit longer to prevent the "threading_cleanup()
# failed to cleanup X threads" warning. The loop above is a weak
# synchronization. At the C level, t_bootstrap() can still be
# running and so _thread.count() still accounts the "almost dead"
# thead.
for _ in range(self.n):
_wait()

def do_finish(self):
self._can_exit = True
Expand Down Expand Up @@ -304,6 +311,7 @@ def f():
self.assertRaises(RuntimeError, lock.release)
finally:
b.do_finish()
b.wait_for_finished()

def test__is_owned(self):
lock = self.locktype()
Expand Down