[CalendarServer-changes] [7278] CalendarServer/trunk/contrib/performance/benchlib.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 30 18:43:07 PDT 2011


Revision: 7278
          http://trac.macosforge.org/projects/calendarserver/changeset/7278
Author:   exarkun at twistedmatrix.com
Date:     2011-03-30 18:43:05 -0700 (Wed, 30 Mar 2011)
Log Message:
-----------
Handle StopIteration from the paramgen iterator and wind down in an orderly manner, rather than erroneously completing with None, losing the collected data

Modified Paths:
--------------
    CalendarServer/trunk/contrib/performance/benchlib.py

Modified: CalendarServer/trunk/contrib/performance/benchlib.py
===================================================================
--- CalendarServer/trunk/contrib/performance/benchlib.py	2011-03-30 20:19:25 UTC (rev 7277)
+++ CalendarServer/trunk/contrib/performance/benchlib.py	2011-03-31 01:43:05 UTC (rev 7278)
@@ -158,27 +158,34 @@
     msg('dtrace started')
 
     start = time()
-    l = []
+    requests = []
     for i in range(concurrency):
-        l.append(once())
+        requests.append(once())
 
-    while True:
+    while requests:
         try:
-            result, index = yield DeferredList(l, fireOnOneCallback=True, fireOnOneErrback=True)
+            result, index = yield DeferredList(requests, fireOnOneCallback=True, fireOnOneErrback=True)
         except FirstError, e:
             e.subFailure.raiseException()
 
         # Get rid of the completed Deferred
-        del l[index]
+        del requests[index]
 
         if time() > start + sampleTime:
             # Wait for the rest of the outstanding requests to keep things tidy
-            yield DeferredList(l)
+            yield DeferredList(requests)
             # And then move on
             break
         else:
             # And start a new operation to replace it
-            l.append(once())
+            try:
+                requests.append(once())
+            except StopIteration:
+                # Ran out of work to do, so paramgen raised a
+                # StopIteration.  This is pretty sad.  Catch it or it
+                # will demolish inlineCallbacks.
+                if len(requests) == concurrency - 1:
+                    msg('exhausted parameter generator')
     
     msg('stopping dtrace')
     leftOver = yield dtrace.stop()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110330/971f82cf/attachment-0001.html>


More information about the calendarserver-changes mailing list