I am using celery 3.1.17 and redis as broker version 3.0.2 in my django program. It's running on Ubuntu 14.04.
In the settings, I defined the CELERYBEAT_SCHEDULE like:
CELERYBEAT_SCHEDULE = {
'task1': {
'task': 'api.tasks.exsample.task1',
'schedule': crontab(hour=1, minute=0),
'args': ()
},
'task2': {
'task': 'api.tasks.exsample.task2',
'schedule': crontab(hour=1, minute=30),
'args': ()
},
'task3': {
'task': 'api.tasks.exsample.task3',
'schedule': crontab(hour=2, minute=0),
'args': ()
},
'task4': {
'task': 'api.tasks.exsample.task4',
'schedule': crontab(hour=2, minute=30),
'args': ()
},
'task5': {
'task': 'api.tasks.exsample.task5',
'schedule': crontab(hour=2, minute=40),
'args': ()
},
'task6': {
'task': ''api.tasks.exsample.task6',
'schedule': crontab(hour=2, minute=50),
'args': ()
},
}
Here is the problem:
If the tasks finish before the schedule time of next task, it works all right. But if a task runs for a long time, say, task1 runs for two hours, then the later tasks would execute for several times each. If I restart celery and celerybeat, sometimes it still have overtime tasks, but sometimes not.
It confused me a lot. I have been reading the celery docs for a while, but could not figure out why. Could anybody tell me why this happens, how celery manages its message and task if the task queue is blocked or celery is restarted?