我需要在特定的芹菜實例上運行一些任務。所以我配置的隊列:芹菜和路由
celeryconfig.py:
CELERY_QUEUES = {
'celery': {
'exchange': 'celery',
'binding_key': 'celery',
},
'import': {
'exchange': 'import',
'binding_key': 'import.products',
},
}
CELERY_ROUTES = {
'celery_tasks.import_tasks.test': {
'queue': 'import',
'routing_key': 'import.products',
},
}
import_tasks.py:
@task
def test():
print 'test'
@task(exchange='import', routing_key='import.products')
def test2
print 'test2'
然後我開始celeryd:
celeryd -c 2 -l INFO -Q import
並嘗試執行任務。 'test'執行但'test2'不執行。但我不想在CELERY_ROUTES中指定每個導入任務。我如何指定哪個隊列應該在任務定義中執行任務?
哦,忘了說我使用redis作爲經紀人。 –