[Python-checkins] cpython (3.1): Try to fix sporadic failure in test_thread/test_threading

antoine.pitrou python-checkins at python.org
Mon Apr 4 22:00:51 CEST 2011


http://hg.python.org/cpython/rev/04b5cd2f8c87
changeset:   69142:04b5cd2f8c87
branch:      3.1
parent:      69132:36d92e923a1a
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Mon Apr 04 21:59:09 2011 +0200
summary:
  Try to fix sporadic failure in test_thread/test_threading

files:
  Lib/test/lock_tests.py |  8 +++++++-
  1 files changed, 7 insertions(+), 1 deletions(-)


diff --git a/Lib/test/lock_tests.py b/Lib/test/lock_tests.py
--- a/Lib/test/lock_tests.py
+++ b/Lib/test/lock_tests.py
@@ -141,7 +141,13 @@
         # We run many threads in the hope that existing threads ids won't
         # be recycled.
         Bunch(f, 15).wait_for_finished()
-        self.assertEqual(n, len(threading.enumerate()))
+        if len(threading.enumerate()) != n:
+            # There is a small window during which a Thread instance's
+            # target function has finished running, but the Thread is still
+            # alive and registered.  Avoid spurious failures by waiting a
+            # bit more (seen on a buildbot).
+            time.sleep(0.4)
+            self.assertEqual(n, len(threading.enumerate()))
 
 
 class LockTests(BaseLockTests):

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list