|
@@ -20,7 +20,7 @@ from celery.utils.log import get_logger
|
|
|
from . import state
|
|
|
from .state import revoked
|
|
|
|
|
|
-TASK_INFO_FIELDS = ('exchange', 'routing_key', 'rate_limit')
|
|
|
+DEFAULT_TASK_INFO_ITEMS = ('exchange', 'routing_key', 'rate_limit')
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
|
|
@@ -200,12 +200,13 @@ def dump_revoked(panel, **kwargs):
|
|
|
|
|
|
|
|
|
@Panel.register
|
|
|
-def dump_tasks(panel, **kwargs):
|
|
|
+def dump_tasks(panel, taskinfoitems=None, **kwargs):
|
|
|
tasks = panel.app.tasks
|
|
|
+ taskinfoitems = taskinfoitems or DEFAULT_TASK_INFO_ITEMS
|
|
|
|
|
|
def _extract_info(task):
|
|
|
fields = dict((field, str(getattr(task, field, None)))
|
|
|
- for field in TASK_INFO_FIELDS
|
|
|
+ for field in taskinfoitems
|
|
|
if getattr(task, field, None) is not None)
|
|
|
info = map('='.join, fields.items())
|
|
|
if not info:
|
|
@@ -266,28 +267,14 @@ def shutdown(panel, msg='Got shutdown from remote', **kwargs):
|
|
|
@Panel.register
|
|
|
def add_consumer(panel, queue, exchange=None, exchange_type=None,
|
|
|
routing_key=None, **options):
|
|
|
- cset = panel.consumer.task_consumer
|
|
|
- exchange = queue if exchange is None else exchange
|
|
|
- routing_key = queue if routing_key is None else routing_key
|
|
|
- exchange_type = 'direct' if exchange_type is None else exchange_type
|
|
|
- if not cset.consuming_from(queue):
|
|
|
- q = panel.app.amqp.queues.add(queue,
|
|
|
- exchange=exchange,
|
|
|
- exchange_type=exchange_type,
|
|
|
- routing_key=routing_key, **options)
|
|
|
- cset.add_queue(q)
|
|
|
- cset.consume()
|
|
|
- logger.info('Started consuming from %r', queue)
|
|
|
- return {'ok': 'started consuming from %r' % (queue, )}
|
|
|
- else:
|
|
|
- return {'ok': 'already consuming from %r' % (queue, )}
|
|
|
+ panel.consumer.add_task_queue(queue, exchange, exchange_type,
|
|
|
+ routing_key, **options)
|
|
|
+ return {'ok': 'add consumer %r' % (queue, )}
|
|
|
|
|
|
|
|
|
@Panel.register
|
|
|
def cancel_consumer(panel, queue=None, **_):
|
|
|
- panel.app.amqp.queues.select_remove(queue)
|
|
|
- cset = panel.consumer.task_consumer
|
|
|
- cset.cancel_by_queue(queue)
|
|
|
+ panel.consumer.cancel_task_queue(queue)
|
|
|
return {'ok': 'no longer consuming from %s' % (queue, )}
|
|
|
|
|
|
|