diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-09-13 23:41:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-13 23:41:08 (GMT) |
commit | 096ae3373abac2c8b3a26a3fe33cc8bd4cbccd4e (patch) | |
tree | 49d2aec0cb8590cbb2a2f4043e4ce0a940b27746 /Lib | |
parent | 65bc62052fe5d550cb14c0033e8a2550618fb7b9 (diff) | |
download | cpython-096ae3373abac2c8b3a26a3fe33cc8bd4cbccd4e.zip cpython-096ae3373abac2c8b3a26a3fe33cc8bd4cbccd4e.tar.gz cpython-096ae3373abac2c8b3a26a3fe33cc8bd4cbccd4e.tar.bz2 |
bpo-31234: Try to fix lock_tests warning (#3557)
Try to fix the "Warning -- threading_cleanup() failed to cleanup 1
threads" warning in test.lock_tests: wait a little bit longer to give
time to the threads to complete.
Warning seen on test_thread and test_importlib.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/lock_tests.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/lock_tests.py b/Lib/test/lock_tests.py index 4fa154f..e8fa4f9 100644 --- a/Lib/test/lock_tests.py +++ b/Lib/test/lock_tests.py @@ -54,6 +54,13 @@ class Bunch(object): 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 @@ -304,6 +311,7 @@ class RLockTests(BaseLockTests): self.assertRaises(RuntimeError, lock.release) finally: b.do_finish() + b.wait_for_finished() def test__is_owned(self): lock = self.locktype() |