芹菜 3.1.11
设置.py
# Celery transport
BROKER_URL = 'django://'
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
from celery.schedules import crontab
CELERYBEAT_SCHEDULE = {
'every-minute': {
'task': 'tasks.sync_oracle_history',
'schedule': crontab(minute='*/1'),
},
}
在 project.apps.proj 文件夹中,添加一个 tasks.py
from __future__ import absolute_import
from celery import task
@task(name='tasks.sync_oracle_history')
def sync_oracle_history():
print "="*30
print "TODO: sync_oracle_history pending"
不知道,欢迎给我任何提示。
在 bash shell 中,运行命令时:celery beat -A proj -l info,只发送到队列,不运行任务,
但是更改命令 celery worker -A proj -l info,任务会触发。
Beat 不执行任务,它只是发送消息。 你需要一个 beat 实例和一个 worker 实例!
谢谢@问
嗨,每次我想运行任务时,我怎么能不使用这些命令? @xiaods @问
最有用的评论
Beat 不执行任务,它只是发送消息。 你需要一个 beat 实例和一个 worker 实例!