celery beat计划程序未使用crontab计划任务

问题描述

Celery Beat无法使用crontab计划任务。它在随机时间安排。有时,它每隔一分钟安排一次。有时每两分钟一次,等等。 在配置的时间"schedule": crontab(hour='*/1')和将任务发送给工作人员的时间之间没有关系!

不知道这是怎么回事。

这是我的celery_test.py:

from kombu import Queue,Exchange
from celery import Celery,shared_task,group,chord
from celery.schedules import crontab

app = Celery('celery_demo',broker='amqp://abcduser:abcdpassword@localhost/abcd_vhost',backend='rpc://',include=['celery_demo.tasks'])

app.conf.beat_schedule = {
    "trigger-call_publisher": {
        "task": "celery_demo.tasks.call_publisher","schedule": crontab(hour='*/1')

以下是我的task.py:

import sys

sys.path.append("..")

from celery_demo.celery_test import app

@app.task
def call_publisher():
    print("Say Hello")

if __name__ == '__main__':
    call_publisher.delay()

    }
}

以下是这样的输出,其中每分钟发送一次任务:

enter image description here

解决方法

我认为让dor每小时运行一次,或者您只用一分钟:

crontab(minute='*/60')

或小时+分钟:

crontab(minute=0,hour='*/1')

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...