[CalendarServer-changes] [15371] CalendarServer/trunk/calendarserver

source_changes at macosforge.org source_changes at macosforge.org
Sat Dec 5 08:56:32 PST 2015


Revision: 15371
          http://trac.calendarserver.org//changeset/15371
Author:   cdaboo at apple.com
Date:     2015-12-05 08:56:31 -0800 (Sat, 05 Dec 2015)
Log Message:
-----------
Make sure the threadpool starts up first once the reactor starts running. Also delay other services' start up actions until the reactor has started (thus ensuring that when they run the threadpool is already running).

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/push/applepush.py
    CalendarServer/trunk/calendarserver/tap/caldav.py

Modified: CalendarServer/trunk/calendarserver/push/applepush.py
===================================================================
--- CalendarServer/trunk/calendarserver/push/applepush.py	2015-12-05 00:03:23 UTC (rev 15370)
+++ CalendarServer/trunk/calendarserver/push/applepush.py	2015-12-05 16:56:31 UTC (rev 15371)
@@ -588,7 +588,7 @@
     def startService(self):
         self.log.debug("APNProviderService startService")
         self.factory = APNProviderFactory(self, self.store)
-        self.connect(self.factory)
+        self.reactor.callWhenRunning(self.connect, self.factory)
 
 
     def stopService(self):
@@ -807,7 +807,7 @@
     def startService(self):
         self.log.debug("APNFeedbackService startService")
         self.factory = APNFeedbackFactory(self.store)
-        self.checkForFeedback()
+        self.reactor.callWhenRunning(self.checkForFeedback)
 
 
     def stopService(self):

Modified: CalendarServer/trunk/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/caldav.py	2015-12-05 00:03:23 UTC (rev 15370)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py	2015-12-05 16:56:31 UTC (rev 15371)
@@ -581,12 +581,19 @@
         self.doPrincipalPurging = doPrincipalPurging
 
 
+    def startService(self):
+        # Do the actual DB work after the reactor has started up
+        from twisted.internet import reactor
+        reactor.callWhenRunning(self.initializeWork)
+
+
     @inlineCallbacks
-    def startService(self):
+    def initializeWork(self):
         # Note: the "seconds in the future" args are being set to the LogID
         # numbers to spread them out.  This is only needed until
         # ultimatelyPerform( ) handles groups correctly.  Once that is fixed
         # these can be set to zero seconds in the future.
+
         if self.doImip:
             yield scheduleNextMailPoll(
                 self.store,
@@ -786,6 +793,13 @@
                 .format(config.ProcessType)
             )
         else:
+            # Always want a thread pool - so start it here before we start anything else
+            # so that it is started before any other callWhenRunning callables. This avoids
+            # a race condition that could cause a deadlock with our long-lived ADBAPI2
+            # connections which grab and hold a thread.
+            from twisted.internet import reactor
+            reactor.getThreadPool()
+
             #
             # Configure Memcached Client Pool
             #
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20151205/95ea5174/attachment.html>


More information about the calendarserver-changes mailing list