Try to fix sporadic failure in test_thread/test_threading

This commit is contained in:
Antoine Pitrou 2011-04-04 21:59:09 +02:00
parent b35f29a0e0
commit 45fdb457da
1 changed files with 7 additions and 1 deletions

View 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):