[CalendarServer-changes] [6137] CalendarServer/trunk/contrib/performance/benchmark.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Aug 19 14:20:02 PDT 2010


Revision: 6137
          http://trac.macosforge.org/projects/calendarserver/changeset/6137
Author:   exarkun at twistedmatrix.com
Date:     2010-08-19 14:20:01 -0700 (Thu, 19 Aug 2010)
Log Message:
-----------
Fix shutdown cleanup for the case where a dtrace process startup had to be retried

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

Modified: CalendarServer/trunk/contrib/performance/benchmark.py
===================================================================
--- CalendarServer/trunk/contrib/performance/benchmark.py	2010-08-19 21:19:44 UTC (rev 6136)
+++ CalendarServer/trunk/contrib/performance/benchmark.py	2010-08-19 21:20:01 UTC (rev 6137)
@@ -148,7 +148,7 @@
     def _startDTrace(self, pid):
         started = Deferred()
         stopped = Deferred()
-        self.dtraces[pid] = reactor.spawnProcess(
+        process = reactor.spawnProcess(
             IOMeasureConsumer(started, stopped),
             "/usr/sbin/dtrace",
             ["/usr/sbin/dtrace", 
@@ -166,9 +166,16 @@
             reason.trap(DTraceBug)
             print 'Dtrace startup failed (', reason.getErrorMessage().strip(), '), retrying.'
             return self._startDTrace(pid)
-        started.addErrback(eintr)
-        stopped.addCallback(self._cleanup, pid)
-        stopped.addCallback(self._parse)
+        def ready(passthrough):
+            # Once the dtrace process is ready, save the state and
+            # have the stopped Deferred deal with the results.  We
+            # don't want to do either of these for failed dtrace
+            # processes.
+            self.dtraces[pid] = process
+            stopped.addCallback(self._cleanup, pid)
+            stopped.addCallback(self._parse)
+            return passthrough
+        started.addCallbacks(ready, eintr)
         return started, stopped
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100819/656db96f/attachment.html>


More information about the calendarserver-changes mailing list