芹菜时间表不起作用

时间:2015-02-18 15:17:33

标签: python celery

我正在使用芹菜并尝试运行 corntab 。下面是我的celery.py

from __future__ import absolute_import
from celery.schedules import crontab


from celery import Celery

app = Celery('Celery_1',
             broker='amqp://test:test@localhost//',
             include=['Celery_1.tasks'])

# Optional configuration, see the application user guide.
app.conf.update(
    CELERY_TASK_RESULT_EXPIRES=3600,
    CELERYBEAT_SCHEDULE = {
    'T1': {
        'task': 'Celery_1.tasks.add',
        'schedule': crontab(minute='*/1'),
        'args': (4, 5)
}
},
    CELERY_IMPORTS = ('Celery_1.tasks', )

)

if __name__ == '__main__':
    app.start()

我的tasks.py

from __future__ import absolute_import

from Celery_1.celery import app


@app.task(name='Celery_1.add')
def add(x, y):
    return x + y

当我按芹菜赛程安排时

enter image description here

但每分钟都没有运行任务。任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

您应该以这种方式运行它(仍然在Celery_1目录中):

echo $null >> __init__.py #to make your directory a python project cd .. celery -A Celery_1 beat

Celery_1是您应用的名称。