python - 芹菜 - 修改调度程序的时间
python - celery - modify time on scheduler
time = 5
app.conf.update(
CELERY_TASK_SERIALIZER='json',
CELERY_ACCEPT_CONTENT=['json'], # Ignore other content
CELERY_RESULT_SERIALIZER='json',
CELERY_TIMEZONE='Asia/Seoul',
CELERY_ENABLE_UTC=False,
CELERYBEAT_SCHEDULE = {
"ADDING TASK": {
"task": "add",
"schedule": time,
'args': (16, 16)
}
}
)
我试图在 运行 时更改时间。
但是这个方法行不通。
如何在 运行
时使用 celery scheduler 更改时间
默认节拍调度程序只从静态设置中读取。您还可以 add entries 使用 add_periodic_task
.
您也可以提供自己的 custom scheduler class。例如,django-celery-beat
提供了一个 DatabaseScheduler
允许您从数据库中读取和更新计划任务。
time = 5
app.conf.update(
CELERY_TASK_SERIALIZER='json',
CELERY_ACCEPT_CONTENT=['json'], # Ignore other content
CELERY_RESULT_SERIALIZER='json',
CELERY_TIMEZONE='Asia/Seoul',
CELERY_ENABLE_UTC=False,
CELERYBEAT_SCHEDULE = {
"ADDING TASK": {
"task": "add",
"schedule": time,
'args': (16, 16)
}
}
)
我试图在 运行 时更改时间。 但是这个方法行不通。 如何在 运行
时使用 celery scheduler 更改时间默认节拍调度程序只从静态设置中读取。您还可以 add entries 使用 add_periodic_task
.
您也可以提供自己的 custom scheduler class。例如,django-celery-beat
提供了一个 DatabaseScheduler
允许您从数据库中读取和更新计划任务。