我在Django中的芹菜设置:
CELERY_BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TASK_SERIALIZER = 'json'
CELERY_QUEUES = (
Queue('high', routing_key='high'),
Queue('normal', routing_key='normal'),
)
CELERY_DEFAULT_QUEUE = 'normal'
如果我在任务中设置队列名称,则可以使用。但是,如果我不这样做,则默认队列设置将不起作用。
# It's ok
@periodic_task(run_every=timedelta(minutes=10), name='Delete props', queue='normal')
def delete_props():
delete_props()
# It doesn't work
@periodic_task(run_every=timedelta(minutes=10), name='Delete props')
def delete_props():
delete_props()
如何设置默认队列并且不在任务参数中设置?