【问题标题】:celery schedule not working芹菜时间表不起作用
【发布时间】:2015-02-18 15:17:33
【问题描述】:

我正在使用 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

当我按 celery beat 安排时

但它并不是每分钟都在运行任务。谁能帮帮我?

【问题讨论】:

  • 您的问题解决了吗?如何?我也面临同样的问题

标签: python celery


【解决方案1】:

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

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

Celery_1 是您应用的名称。

【讨论】:

    猜你喜欢
    • 2016-04-24
    • 1970-01-01
    • 2015-02-15
    • 2015-12-16
    • 2019-01-29
    • 1970-01-01
    • 1970-01-01
    • 2020-12-09
    • 1970-01-01
    相关资源
    最近更新 更多