Browse Source

Show listener info in the 'stats' control command

Ask Solem 14 years ago
parent
commit
20c1fd6734
3 changed files with 13 additions and 2 deletions
  1. 3 2
      celery/utils/info.py
  2. 1 0
      celery/worker/control/builtins.py
  3. 9 0
      celery/worker/listener.py

+ 3 - 2
celery/utils/info.py

@@ -38,8 +38,9 @@ def format_queues(queues, indent=0):
     return textindent(info, indent=indent)
 
 
-def get_broker_info():
-    broker_connection = establish_connection()
+def get_broker_info(broker_connection=None):
+    if broker_connection is None:
+        broker_connection = establish_connection()
 
     carrot_backend = broker_connection.backend_cls
     if carrot_backend and not isinstance(carrot_backend, str):

+ 1 - 0
celery/worker/control/builtins.py

@@ -153,6 +153,7 @@ def dump_active(panel, safe=False, **kwargs):
 @Panel.register
 def stats(panel, **kwargs):
     return {"total": state.total_count,
+            "listener": panel.listener.info,
             "pool": panel.listener.pool.info}
 
 

+ 9 - 0
celery/worker/listener.py

@@ -90,6 +90,7 @@ from celery.messaging import establish_connection
 from celery.messaging import get_consumer_set, BroadcastConsumer
 from celery.exceptions import NotRegistered
 from celery.datastructures import SharedCounter
+from celery.utils.info import get_broker_info
 
 RUN = 0x1
 CLOSE = 0x2
@@ -451,3 +452,11 @@ class CarrotListener(object):
         """
         self.logger.debug("CarrotListener: Stopping consumers...")
         self.stop_consumers(close=False)
+
+    @property
+    def info(self):
+        conninfo = {}
+        if self.connection:
+            conninfo = get_broker_info(self.connection)
+        return {"broker": conninfo,
+                "prefetch_count": self.qos.next}