Browse Source

Fixes load_average to also support Windows. Closes #1110

frol 12 years ago
parent
commit
10bb5a6f58
1 changed files with 9 additions and 2 deletions
  1. 9 2
      celery/utils/sysinfo.py

+ 9 - 2
celery/utils/sysinfo.py

@@ -8,8 +8,15 @@ from math import ceil
 from kombu.utils import cached_property
 
 
-def load_average():
-    return tuple(ceil(l * 1e2) / 1e2 for l in os.getloadavg())
+if hasattr(os, 'getloadavg'):
+
+    def load_average():
+        return tuple(ceil(l * 1e2) / 1e2 for l in os.getloadavg())
+
+else:  # Windows doesn't have getloadavg
+
+    def load_average():  # noqa
+        return (0.0, 0.0, 0.0)
 
 
 class df(object):