Parcourir la source

Make information about the pool available to the listener

Ask Solem il y a 14 ans
Parent
commit
09599466c5

+ 8 - 0
celery/concurrency/processes/__init__.py

@@ -102,3 +102,11 @@ class TaskPool(object):
             [errback(ret_value) for errback in errbacks]
         else:
             [callback(ret_value) for callback in callbacks]
+
+    @property
+    def info(self):
+        return {"max-concurrency": self.limit,
+                "processes": [p.pid for p in self._pool._pool],
+                "max-tasks-per-child": self.maxtasksperchild,
+                "put-guarded-by-semaphore": self.putlocks,
+                "timeouts": (self.soft_timeout, self.timeout)}

+ 2 - 1
celery/worker/__init__.py

@@ -176,7 +176,8 @@ class WorkController(object):
                                     hostname=self.hostname,
                                     send_events=self.send_events,
                                     init_callback=self.ready_callback,
-                                    initial_prefetch_count=prefetch_count)
+                                    initial_prefetch_count=prefetch_count,
+                                    pool=self.pool)
 
         # The order is important here;
         #   the first in the list is the first to start,

+ 2 - 1
celery/worker/listener.py

@@ -203,7 +203,7 @@ class CarrotListener(object):
 
     def __init__(self, ready_queue, eta_schedule, logger,
             init_callback=noop, send_events=False, hostname=None,
-            initial_prefetch_count=2):
+            initial_prefetch_count=2, pool=None):
         self.connection = None
         self.task_consumer = None
         self.ready_queue = ready_queue
@@ -215,6 +215,7 @@ class CarrotListener(object):
         self.initial_prefetch_count = initial_prefetch_count
         self.event_dispatcher = None
         self.heart = None
+        self.pool = pool
         self.control_dispatch = ControlDispatch(logger=logger,
                                                 hostname=self.hostname,
                                                 listener=self)