[Python-checkins] cpython (merge 3.2 -> default): Try to fix sporadic failure in test_thread/test_threading

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


http://hg.python.org/cpython/rev/877e152c2eee
changeset: 69144:877e152c2eee
parent: 69141:4fa9bfa21a7e
parent: 69143:8d5ea25d79d0
user: Antoine Pitrou <solipsis at pitrou.net>
date: Mon Apr 04 22:00:45 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
@@ -149,7 +149,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()))
 
 def test_timeout(self):
 lock = self.locktype()
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /