Parcourir la source

Only change QOS(prefetch_count) if it has changed

Ask Solem il y a 15 ans
Parent
commit
a64768b653
1 fichiers modifiés avec 4 ajouts et 1 suppressions
  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):