celery task装饰器能制定某一个队列或者指明routing_key么


from celery.task import task, periodic_task

在periodic_task中可以 明确指明routing_key ,使用flower查看也确实绑定了,task各种绑不上


 #@task(routing_key=settings.LOW_PRIORITY_QUEUE)
@periodic_task(run_every=timedelta(seconds=10), routing_key=settings.LOW_PRIORITY_QUEUE)
def only_a_test():
    print 'a simple task'
    print settings.LOW_PRIORITY_QUEUE
    print '========'

队列配置 用了简单的默认值


 QUEUE_VARIANT = CONFIG_PREFIX.lower()

CELERY_DEFAULT_EXCHANGE = 'edx.{0}core'.format(QUEUE_VARIANT)

HIGH_PRIORITY_QUEUE = 'edx.{0}core.high'.format(QUEUE_VARIANT)
DEFAULT_PRIORITY_QUEUE = 'edx.{0}core.default'.format(QUEUE_VARIANT)
LOW_PRIORITY_QUEUE = 'edx.{0}core.low'.format(QUEUE_VARIANT)
HIGH_MEM_QUEUE = 'edx.{0}core.high_mem'.format(QUEUE_VARIANT)

CELERY_DEFAULT_QUEUE = DEFAULT_PRIORITY_QUEUE
CELERY_DEFAULT_ROUTING_KEY = DEFAULT_PRIORITY_QUEUE

CELERY_QUEUES = { 
    HIGH_PRIORITY_QUEUE: {}, 
    LOW_PRIORITY_QUEUE: {}, 
    DEFAULT_PRIORITY_QUEUE: {}, 
    HIGH_MEM_QUEUE: {}, 
}

celery task装饰器能制定某一个队列或者指明routing_key么?

django celery

两米下的氮磷钾 10 years, 3 months ago

Your Answer