[CalendarServer-changes] [11686] CalendarServer/trunk/twext/web2/metafd.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Sep 12 18:17:42 PDT 2013


Revision: 11686
          http://trac.calendarserver.org//changeset/11686
Author:   glyph at apple.com
Date:     2013-09-12 18:17:42 -0700 (Thu, 12 Sep 2013)
Log Message:
-----------
Make the implementation a bit more readable, move closer to law of demeter happiness

Modified Paths:
--------------
    CalendarServer/trunk/twext/web2/metafd.py

Modified: CalendarServer/trunk/twext/web2/metafd.py
===================================================================
--- CalendarServer/trunk/twext/web2/metafd.py	2013-09-13 00:24:45 UTC (rev 11685)
+++ CalendarServer/trunk/twext/web2/metafd.py	2013-09-13 01:17:42 UTC (rev 11686)
@@ -360,12 +360,11 @@
         self._outstandingRequests = current # preserve for or= field in log
         maximum = self.maxRequests
         overloaded = (current >= maximum)
-        if overloaded:
-            for f in self.factories:
-                f.myServer.myPort.stopReading()
-        else:
-            for f in self.factories:
-                f.myServer.myPort.startReading()
+        for f in self.factories:
+            if overloaded:
+                f.loadAboveMaximum()
+            else:
+                f.loadNominal()
 
 
     @property # make read-only
@@ -401,6 +400,20 @@
         self.maxRequests = limiter.maxRequests
 
 
+    def loadAboveMaximum(self):
+        """
+        The current server load has exceeded the maximum allowable.
+        """
+        self.myServer.myPort.stopReading()
+
+
+    def loadNominal(self):
+        """
+        The current server load is nominal; proceed with reading requests.
+        """
+        self.myServer.myPort.startReading()
+
+
     @property
     def outstandingRequests(self):
         return self.limiter.outstandingRequests
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130912/633d6b80/attachment.html>


More information about the calendarserver-changes mailing list