[CalendarServer-changes] [15005] twext/trunk/twext/enterprise/jobqueue.py

source_changes at macosforge.org source_changes at macosforge.org
Mon Jul 27 12:39:05 PDT 2015


Revision: 15005
          http://trac.calendarserver.org//changeset/15005
Author:   cdaboo at apple.com
Date:     2015-07-27 12:39:05 -0700 (Mon, 27 Jul 2015)
Log Message:
-----------
Wait for work queue check txn to finish after service is stopped.

Modified Paths:
--------------
    twext/trunk/twext/enterprise/jobqueue.py

Modified: twext/trunk/twext/enterprise/jobqueue.py
===================================================================
--- twext/trunk/twext/enterprise/jobqueue.py	2015-07-27 18:26:09 UTC (rev 15004)
+++ twext/trunk/twext/enterprise/jobqueue.py	2015-07-27 19:39:05 UTC (rev 15005)
@@ -1987,6 +1987,7 @@
         self._lastMinPriority = WORK_PRIORITY_LOW
         self._timeOfLastWork = time.time()
         self._actualPollInterval = self.queuePollInterval
+        self._inWorkCheck = False
 
 
     def addPeerConnection(self, peer):
@@ -2114,6 +2115,8 @@
             if not self.running or self.disableWorkProcessing:
                 returnValue(None)
 
+            self._inWorkCheck = True
+
             # Check the overall service load - if overloaded skip this poll cycle.
             # FIXME: need to include capacity of other nodes. For now we only check
             # our own capacity and stop processing if too busy. Other nodes that
@@ -2228,6 +2231,7 @@
                 if txn:
                     yield txn.commit()
                     txn = None
+                self._inWorkCheck = False
 
             if nextJob is not None:
                 try:
@@ -2382,7 +2386,13 @@
         for peer in self.peers:
             peer.transport.abortConnection()
 
+        # Wait for any active work check to finish
+        while self._inWorkCheck:
+            d = Deferred()
+            self.reactor.callLater(0.5, lambda : d.callback(None))
+            yield d
 
+
     def activeNodes(self, txn):
         """
         Load information about all other nodes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150727/7749e3c1/attachment.html>


More information about the calendarserver-changes mailing list