Browse Source

Only change QOS(prefetch_count) if it has changed

Ask Solem 15 years ago
parent
commit
a64768b653
1 changed files with 4 additions and 1 deletions
  1. 4 1
      celery/worker/__init__.py

+ 4 - 1
celery/worker/__init__.py

@@ -89,8 +89,11 @@ class CarrotListener(object):
 
         self.logger.debug("CarrotListener: Ready to accept tasks!")
 
+        prev_pcount = None
         while True:
-            self.task_consumer.qos(prefetch_count=int(self.prefetch_count))
+            if not prev_pcount or int(self.prefetch_count) != prev_pcount:
+                self.task_consumer.qos(prefetch_count=int(self.prefetch_count))
+                prev_pcount = int(self.prefetch_count)
             it.next()
 
     def stop(self):