[Python-checkins] r85445 - in python/branches/release31-maint: Lib/test/test_threaded_import.py

antoine.pitrou python-checkins at python.org
Thu Oct 14 01:50:54 CEST 2010


Author: antoine.pitrou
Date: Thu Oct 14 01:50:54 2010
New Revision: 85445
Log:
Merged revisions 85444 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
 r85444 | antoine.pitrou | 2010年10月14日 01:48:39 +0200 (jeu., 14 oct. 2010) | 6 lines
 
 Fix (hopefully) occasional failures in test_threaded_import.
 `done` could be released multiple times because of concurrent
 execution. We convert it to an Event, where calling set()
 multiple times is not a problem.
........
Modified:
 python/branches/release31-maint/ (props changed)
 python/branches/release31-maint/Lib/test/test_threaded_import.py
Modified: python/branches/release31-maint/Lib/test/test_threaded_import.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_threaded_import.py	(original)
+++ python/branches/release31-maint/Lib/test/test_threaded_import.py	Thu Oct 14 01:50:54 2010
@@ -33,7 +33,7 @@
 done_tasks.append(thread.get_ident())
 finished = len(done_tasks) == N
 if finished:
- done.release()
+ done.set()
 
 # Create a circular import structure: A -> C -> B -> D -> A
 # NOTE: `time` is already loaded and therefore doesn't threaten to deadlock.
@@ -99,8 +99,7 @@
 # This triggers on, e.g., from test import autotest.
 raise unittest.SkipTest("can't run when import lock is held")
 
- done = thread.allocate_lock()
- done.acquire()
+ done = threading.Event()
 for N in (20, 50) * 3:
 if verbose:
 print("Trying", N, "threads ...", end=' ')
@@ -112,13 +111,13 @@
 pass
 errors = []
 done_tasks = []
+ done.clear()
 for i in range(N):
 thread.start_new_thread(task, (N, done, done_tasks, errors,))
- done.acquire()
+ done.wait(60)
 self.assertFalse(errors)
 if verbose:
 print("OK.")
- done.release()
 
 def test_parallel_module_init(self):
 self.check_parallel_module_init()


More information about the Python-checkins mailing list

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