我正在运行芹菜v4.0.2,rabbitmq 3.6.10和烧瓶。
以下代码构建了我的Celery对象。
def make_celery(app):
celery = Celery(app.import_name, backend='rpc://', broker='amqp://', include=['jobs'])
celery.conf.update(app.config)
TaskBase = celery.Task
class ContextTask(TaskBase):
abstract = True
def __call__(self, *args, **kwargs):
with app.app_context():
return TaskBase.__call__(self, *args, **kwargs)
celery.Task = ContextTask
return celery
logger.init_logger(console=True, log_dir=False, verbose=False)
logger.info('Starting Application')
app = Flask(__name__, instance_relative_config=True)
celery = make_celery(app)
然后我使用以下内容向节拍时间表添加任务,
celery.add_periodic_task(10.0, APP.jobs.ex.s())
print celery.conf.beat_schedule
>> {'APP.jobs.ex()': {u'kwargs': {}, u'task': u'APP.jobs.ex', u'options': {}, u'args': (), u'schedule': 10.0}}
我在这里经营一名工人,这适用于添加正常任务,
celery -A APP.celery worker -l info
我在这里运行节拍调度程序,
celery -A APP.celery beat -l info
>> celery beat v4.0.2 (latentcall) is starting.
__ - ... __ - _
LocalTime -> 2017-07-27 16:31:16
Configuration ->
. broker -> amqp://guest:**@localhost:5672//
. loader -> celery.loaders.app.AppLoader
. scheduler -> celery.beat.PersistentScheduler
. db -> celerybeat-schedule
. logfile -> [stderr]@%INFO
. maxinterval -> 5.00 minutes (300s)
[2017-07-27 16:31:16,320: INFO/MainProcess] beat: Starting...
但是,从这一点来说没有任何反应。有什么想法吗?