]> granicus.if.org Git - python/commitdiff
Try to fix sporadic failure in test_thread/test_threading
authorAntoine Pitrou <solipsis@pitrou.net>
Mon, 4 Apr 2011 19:59:09 +0000 (21:59 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Mon, 4 Apr 2011 19:59:09 +0000 (21:59 +0200)
Lib/test/lock_tests.py

index 04f7422c8de76917d34ce9a7cab9085716e5cd57..22c690059297a8ceb3c5db90ff5cfc4be01de64f 100644 (file)
@@ -141,7 +141,13 @@ class BaseLockTests(BaseTestCase):
         # 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):