I'm trying to set up two tasks that both run every minute. Is there any way to group them in one to run?
I specified CELERYBEAT_SCHEDULE
in my celeryconfig.py
as following:
CELERYBEAT_SCHEDULE = {
'every-minute': {
'task': 'tasks.add',
'schedule': crontab(minute='*/1'),
'args': (1,2)
},
}
So if I want to run two tasks, I would expect something like this?
CELERYBEAT_SCHEDULE = {
'every-minute': {
'task': ['tasks.add','task.multiply'],
'schedule': [crontab(minute='*/1'),crontab(minute='*/1')],
'args': [(1,2),(3,4)]
},
}
However it did not work. Is there any standard way of doing this?
The Celery Documentation: Periodic Tasks states that you can only have the name of the task to be executed (not a list, etc.)
You could create two different schedule entries:
CELERYBEAT_SCHEDULE = {
'every-minute_add': {
'task': 'tasks.add',
'schedule': crontab(minute='*/1'),
'args': (1,2)
},
'every-minute_multiply': {
'task': 'task.multiply',
'schedule': crontab(minute='*/1'),
'args': (3,4)
},
}