Browse Source

Mediator: Don't sleep between gets (reduces CPU usage considerably when rate limits activated)

Ask Solem 14 years ago
parent
commit
006960912e
1 changed files with 10 additions and 10 deletions
  1. 10 10
      celery/worker/controllers.py

+ 10 - 10
celery/worker/controllers.py

@@ -36,17 +36,17 @@ class Mediator(threading.Thread):
     def move(self):
         try:
             # This blocks until there's a message in the queue.
-            task = self.ready_queue.get(timeout=1)
+            task = self.ready_queue.get(timeout=1.0)
         except QueueEmpty:
-            time.sleep(0.2)
-        else:
-            if task.revoked():
-                return
-
-            self.logger.debug(
-                "Mediator: Running callback for task: %s[%s]" % (
-                    task.task_name, task.task_id))
-            self.callback(task) # execute
+            return
+
+        if task.revoked():
+            return
+
+        self.logger.debug(
+            "Mediator: Running callback for task: %s[%s]" % (
+                task.task_name, task.task_id))
+        self.callback(task) # execute
 
     def run(self):
         while not self._shutdown.isSet():