subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1387798 - /subversion/trunk/subversion/tests/cmdline/svntest/main.py
Date Wed, 19 Sep 2012 22:17:07 GMT
Author: stsp
Date: Wed Sep 19 22:17:07 2012
New Revision: 1387798

URL: http://svn.apache.org/viewvc?rev=1387798&view=rev
Log:
* subversion/tests/cmdline/svntest/main.py
  (TestSpawningThread): Protect access to the tests job queue with a mutex.
   This will hopefully fix misaligned progress bars observed on the Windows
   build bot since r1387534. The best explanation I can think of is that race
   conditions could cause an incorrect queue size passed to progress_func().

Modified:
    subversion/trunk/subversion/tests/cmdline/svntest/main.py

Modified: subversion/trunk/subversion/tests/cmdline/svntest/main.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/main.py?rev=1387798&r1=1387797&r2=1387798&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/main.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/main.py Wed Sep 19 22:17:07 2012
@@ -1232,6 +1232,7 @@ class TestSpawningThread(threading.Threa
   def __init__(self, queue, progress_func, tests_total):
     threading.Thread.__init__(self)
     self.queue = queue
+    self.queue_lock = threading.Lock()
     self.results = []
     self.progress_func = progress_func
     self.tests_total = tests_total
@@ -1239,16 +1240,21 @@ class TestSpawningThread(threading.Threa
   def run(self):
     while True:
       try:
+        self.queue_lock.acquire()
         next_index = self.queue.get_nowait()
       except queue.Empty:
         return
+      finally:
+        self.queue_lock.release()
 
       self.run_one(next_index)
 
       # signal progress
       if self.progress_func:
-        self.progress_func(self.tests_total - self.queue.qsize(),
-                           self.tests_total)
+        self.queue_lock.acquire()
+        qsize = self.queue.qsize() 
+        self.queue_lock.release()
+        self.progress_func(self.tests_total - qsize, self.tests_total)
 
   def run_one(self, index):
     command = os.path.abspath(sys.argv[0])



Mime
View raw message