芹菜击败服务旧(删除)任务
Celery beat serving old (removed) task
在supervisor
下,celery beat 为我的一个Django 应用程序向celery worker 提供定期任务。我有 4 个任务,task1
、task2
、task3
和 task4
。最近我做了第 5 个任务:task5
。
我的问题是我从我的工作人员那里注释掉了 task5
,从 settings.py 中删除了它的提及并重新启动了 celerybeat 和我的 celery 工作人员。但我仍然看到 task5
定期出现(自然地在工人的日志中抛出错误)。
为什么会这样,我该如何更新周期性任务?
在settings.py中,我有:
import djcelery
djcelery.setup_loader()
# config settings for Celery Daemon
# Redis broker
BROKER_URL = 'redis://localhost:6379/0'
BROKER_TRANSPORT = 'redis'
# List of modules to import when celery starts, in myapp.tasks form.
CELERY_IMPORTS = ('myapp.tasks', )
CELERY_ALWAYS_EAGER = False
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
#The backend is the resource which returns the results of a completed task from Celery. 6379 is the default port to the redis server.
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_IGNORE_RESULT=True
from datetime import timedelta
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
CELERYBEAT_SCHEDULE = {
'tasks.task1': {
'task': 'tasks.task1',
'schedule': timedelta(seconds=45),
},
'tasks.task2': {
'task': 'tasks.task2',
'schedule': timedelta(seconds=60), # execute every 60 seconds
'args': (),
},
'tasks.task3': {
'task': 'tasks.task3',
'schedule': timedelta(seconds=90), # execute every 90 seconds
'args': (),
},
'tasks.task4': {
'task': 'tasks.task4',
'schedule': timedelta(seconds=90), # execute every 90 seconds
'args': (),
},
}
/etc/supervisor/conf.d/celerybeat.conf 包含以下内容:
command=python manage.py celery beat -l info
directory = /home/myuser/myproject/
environment=PATH="/home/myuser/envs/myenv/bin",VIRTUAL_ENV="/home/myuser/envs/myenv",PYTHONPATH="/home/myuser/envs/myenv/lib/python2.7:/home/myuser/envs/myenv/lib/python2.7/site-packages"
user=mhb11
numprocs=1
stdout_logfile = /etc/supervisor/logs/celerybeat.log
stderr_logfile = /etc/supervisor/logs/celerybeat.log
autostart = true
autorestart = true
startsecs=10
stopwaitsecs = 600
killasgroup=true
priority=999
如果需要,请向我询问更多信息。提前致谢。
我相信您已经有待处理的任务。
您将需要purge them. Or, if you know their id's (note that unless you overrode it, task ids are uniquely generated .. these are not the name of the task), you can also revoke them。
另一个可能的原因是您正在使用
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
您的任务正在存储在您的数据库中,仅通过从 CELERYBEAT_SCHEDULE
中删除它们不会被删除。
您需要删除或禁用不需要的周期性任务(如果您启用了 djcelery 应用程序,可以通过管理员轻松完成)
https://docs.celeryproject.org/en/stable/userguide/configuration.html#std:setting-beat_scheduler
在supervisor
下,celery beat 为我的一个Django 应用程序向celery worker 提供定期任务。我有 4 个任务,task1
、task2
、task3
和 task4
。最近我做了第 5 个任务:task5
。
我的问题是我从我的工作人员那里注释掉了 task5
,从 settings.py 中删除了它的提及并重新启动了 celerybeat 和我的 celery 工作人员。但我仍然看到 task5
定期出现(自然地在工人的日志中抛出错误)。
为什么会这样,我该如何更新周期性任务?
在settings.py中,我有:
import djcelery
djcelery.setup_loader()
# config settings for Celery Daemon
# Redis broker
BROKER_URL = 'redis://localhost:6379/0'
BROKER_TRANSPORT = 'redis'
# List of modules to import when celery starts, in myapp.tasks form.
CELERY_IMPORTS = ('myapp.tasks', )
CELERY_ALWAYS_EAGER = False
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
#The backend is the resource which returns the results of a completed task from Celery. 6379 is the default port to the redis server.
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_IGNORE_RESULT=True
from datetime import timedelta
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
CELERYBEAT_SCHEDULE = {
'tasks.task1': {
'task': 'tasks.task1',
'schedule': timedelta(seconds=45),
},
'tasks.task2': {
'task': 'tasks.task2',
'schedule': timedelta(seconds=60), # execute every 60 seconds
'args': (),
},
'tasks.task3': {
'task': 'tasks.task3',
'schedule': timedelta(seconds=90), # execute every 90 seconds
'args': (),
},
'tasks.task4': {
'task': 'tasks.task4',
'schedule': timedelta(seconds=90), # execute every 90 seconds
'args': (),
},
}
/etc/supervisor/conf.d/celerybeat.conf 包含以下内容:
command=python manage.py celery beat -l info
directory = /home/myuser/myproject/
environment=PATH="/home/myuser/envs/myenv/bin",VIRTUAL_ENV="/home/myuser/envs/myenv",PYTHONPATH="/home/myuser/envs/myenv/lib/python2.7:/home/myuser/envs/myenv/lib/python2.7/site-packages"
user=mhb11
numprocs=1
stdout_logfile = /etc/supervisor/logs/celerybeat.log
stderr_logfile = /etc/supervisor/logs/celerybeat.log
autostart = true
autorestart = true
startsecs=10
stopwaitsecs = 600
killasgroup=true
priority=999
如果需要,请向我询问更多信息。提前致谢。
我相信您已经有待处理的任务。
您将需要purge them. Or, if you know their id's (note that unless you overrode it, task ids are uniquely generated .. these are not the name of the task), you can also revoke them。
另一个可能的原因是您正在使用
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
您的任务正在存储在您的数据库中,仅通过从 CELERYBEAT_SCHEDULE
中删除它们不会被删除。
您需要删除或禁用不需要的周期性任务(如果您启用了 djcelery 应用程序,可以通过管理员轻松完成)
https://docs.celeryproject.org/en/stable/userguide/configuration.html#std:setting-beat_scheduler