[CalendarServer-changes] [3089] CalendarServer/trunk/twistedcaldav/cluster.py

source_changes at macosforge.org source_changes at macosforge.org
Tue Sep 30 16:30:20 PDT 2008


Revision: 3089
          http://trac.macosforge.org/projects/calendarserver/changeset/3089
Author:   wsanchez at apple.com
Date:     2008-09-30 16:30:19 -0700 (Tue, 30 Sep 2008)
Log Message:
-----------
Handle errors from getNCPU() by assuming 1 CPU if it returns 0

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/cluster.py

Modified: CalendarServer/trunk/twistedcaldav/cluster.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/cluster.py	2008-09-29 20:55:15 UTC (rev 3088)
+++ CalendarServer/trunk/twistedcaldav/cluster.py	2008-09-30 23:30:19 UTC (rev 3089)
@@ -210,16 +210,27 @@
 
     if config.MultiProcess['ProcessCount'] == 0:
         try:
-            config.MultiProcess['ProcessCount'] = getNCPU()
-            log.msg("%d processors found, configuring %d processes." % (
-                    config.MultiProcess['ProcessCount'],
-                    config.MultiProcess['ProcessCount']))
+            cpuCount = getNCPU()
+        except NotImplementedError, e:
+            error = str(e)
+        else:
+            if cpuCount > 0:
+                error = None
+            else:
+                error = "No processors detected, which is difficult to believe."
 
-        except NotImplementedError, err:
-            log.msg('Could not autodetect number of CPUs:')
-            log.msg(err)
-            config.MultiProcess['ProcessCount'] = 1
+        if error is None:
+            log.msg(
+                "%d processors found, configuring %d processes."
+                % (cpuCount, cpuCount)
+            )
+        else:
+            log.err("Could not autodetect number of CPUs: %s" % (error,))
+            log.err("Assuming one CPU, configuring one process.")
+            cpuCount = 1
 
+        config.MultiProcess['ProcessCount'] = cpuCount
+
     if config.MultiProcess['ProcessCount'] > 1:
         if config.BindHTTPPorts:
             port = [list(reversed(config.BindHTTPPorts))[0]]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080930/a1f9e309/attachment.html 


More information about the calendarserver-changes mailing list