[Zope3-checkins] SVN: zope.testing/branches/benji-parallelize-subprocesses/src/zope/testing/testrunner/runner.py simplyfy code a little; no need for a queue, a list will do since

Benji York benji at zope.com
Sat Jul 5 15:21:01 EDT 2008


Log message for revision 88044:
  simplyfy code a little; no need for a queue, a list will do since
  list.append is thread-safe
  

Changed:
  U   zope.testing/branches/benji-parallelize-subprocesses/src/zope/testing/testrunner/runner.py

-=-
Modified: zope.testing/branches/benji-parallelize-subprocesses/src/zope/testing/testrunner/runner.py
===================================================================
--- zope.testing/branches/benji-parallelize-subprocesses/src/zope/testing/testrunner/runner.py	2008-07-05 18:51:04 UTC (rev 88043)
+++ zope.testing/branches/benji-parallelize-subprocesses/src/zope/testing/testrunner/runner.py	2008-07-05 19:21:00 UTC (rev 88044)
@@ -16,7 +16,6 @@
 $Id: __init__.py 86232 2008-05-03 15:09:33Z ctheune $
 """
 
-import Queue
 import cStringIO
 import gc
 import glob
@@ -369,7 +368,7 @@
     def runTest(self):
         "Layer set up failure."
 
-def spawn_layer_in_subprocess(queue, options, features, layer_name, layer,
+def spawn_layer_in_subprocess(rans, options, features, layer_name, layer,
         failures, errors, resume_number):
     args = [sys.executable,
             sys.argv[0],
@@ -435,17 +434,17 @@
         nerr -= 1
         errors.append((suberr.readline().strip(), None))
 
-    queue.put(ran)
+    rans.append(ran)
 
 
 def resume_tests(options, features, layers, failures, errors):
-    queue = Queue.Queue()
+    rans = []
     resume_number = 0
     ready_threads = []
     for layer_name, layer, tests in layers:
         ready_threads.append(threading.Thread(
             target=spawn_layer_in_subprocess,
-            args=(queue, options, features, layer_name, layer, failures,
+            args=(rans, options, features, layer_name, layer, failures,
                 errors, resume_number)))
         resume_number += 1
 
@@ -463,13 +462,9 @@
         time.sleep(0.01) # keep the loop from being too tight
 
     # Gather up all the results.
-    rantotal = 0
-    while not queue.empty():
-        rantotal += queue.get()
+    return sum(rans)
 
-    return rantotal
 
-
 def tear_down_unneeded(options, needed, setup_layers, optional=False):
     # Tear down any layers not needed for these tests. The unneeded
     # layers might interfere.



More information about the Zope3-Checkins mailing list