I need to run some tasks on the specific celeryd instance. So I configured queues:
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'
then I start celeryd:
celeryd -c 2 -l INFO -Q import
And try to execute that tasks. ‘test’ executes but ‘test2’ do not. But I don’t want to specify every importing task in the CELERY_ROUTES. How can I specify which queue should execute task in the task definition?
Oh, forgot to say that I’ve used send_task function to execute tasks. And this function doesn’t import tasks. It just sends the name of the task to the queue.
So instead of this:
I wrote: