我有一个芹菜工人,被配置成与redis连接,如下所示:
celery_app_site24x7 = Celery('monitoringExterne.celerys.site24x7',
broker=settings.REDIS['broker'], backend=settings.REDIS['backend'])
celery_app_site24x7.conf.broker_transport_options = {
'visibility_timeout': 36000
}
celery_app_site24x7.conf.socket_timeout = 300
celery_app_site24x7.conf.broker_connection_max_retries = None
celery_app_site24x7.config_from_object('django.conf:settings')
celery_app_site24x7.autodiscover_tasks(lambda: settings.INSTALLED_APPS)问题是,如果Redis关闭并重新建立了连接,则不会执行队列中添加的新任务:
[2020-01-13 10:10:14,517: ERROR/MainProcess] consumer: Cannot connect to redis://xxx.xxx.xxx.xx:6380/10: Error while reading from socket: ('Connection closed by server.',).
Trying again in 2.00 seconds...
[2020-01-13 10:10:16,590: INFO/MainProcess] Connected to redis://xxx.xxx.xxx.xx:6380/10
[2020-01-13 10:10:16,699: INFO/MainProcess] mingle: searching for neighbors
[2020-01-13 10:10:17,766: INFO/MainProcess] mingle: all alone我通过django shell手动调用了一个芹菜任务,如下所示:
celery_tasks.site24x7.test.delay()
它返回异步任务ID,但工作人员不处理此任务。
<AsyncResult:ff634b85-edb5-44d4-bdb1-17a220761fcc>如果我继续以延迟的形式启动任务,队列就会不断增加:
127.0.0.1:6379[10]> llen site24x7
(integer) 4
127.0.0.1:6379[10]> llen site24x7
(integer) 5以下是芹菜状态的输出和检验。
$芹菜-A monitoringExterne --app=monitoringExterne.celerys.site24x7
状态错误:在时间限制内没有节点答复。
$芹菜-A monitoringExterne --app=监控Externe.celerys.site24x7检查活动
错误:在时间限制内没有节点答复。
发布于 2020-01-14 13:52:25
如果您的工作人员没有订阅site24x7队列,那么该队列中的任务数量将不断增加.尝试使用一些类似于:celery -A monitoringExterne.celerys.site24x7 -Q site24x7 -l info的方法来运行这项工作
另外,请记住,-A和--app是相同的标志,您不应该同时使用这两种标志。
如果要获得No nodes replied within time constraint输出,这意味着集群中没有活动的芹菜工人,这也可能是该队列中任务数量增加的原因--没有工作人员来执行它们!
https://stackoverflow.com/questions/59729862
复制相似问题