瀏覽代碼

Avoid hammering the CPU just waiting on the status of task.

Brian Rosner 16 年之前
父節點
當前提交
0f1108f525
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      celery/backends/base.py

+ 3 - 0
celery/backends/base.py

@@ -1,4 +1,6 @@
 """celery.backends.base"""
+import time
+
 from celery.timer import TimeoutTimer
 try:
     import cPickle as pickle
@@ -173,6 +175,7 @@ class BaseBackend(object):
                 return self.get_result(task_id)
             elif status == "FAILURE":
                 raise self.get_result(task_id)
+            time.sleep(0.5) # avoid hammering the CPU checking status.
             timeout_timer.tick()
 
     def process_cleanup(self):