소스 검색

Fixes load_average to also support Windows. Closes #1110

frol 12 년 전
부모
커밋
10bb5a6f58
1개의 변경된 파일9개의 추가작업 그리고 2개의 파일을 삭제
  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
 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):
 class df(object):