python - How to retrieve list of tasks in a queue in Celery?
问题描述
My goal is to retrieve active & reserved tasks on my Celery workers.
I'm using a Django-Celery-Redis framework.
As suggested here: Retrieve list of tasks in a queue in Celery
I have done this to retrieve the tasks:
from your_app.celery import app as my_app
i = my_app.control.inspect()
active_tasks = i.active()
reserved_tasks = i.reserved()
It works well under my local environment.
Online though (I'm using Heroku), it works 5% of the time & 95% of the time I get some errors.
I get two types of errors, that randomly appears:
raise ConnectionError(str(exc)) from exc
kombu.exceptions.OperationalError: Error 0 connecting to THE_REDIS_SERVER. Error.
Or I get a None
response from my calls.
I tried to configure some timeouts because by default control.inspect
has timeout = 1.0
.
from your_app.celery import app as my_app
i = my_app.control.inspect(timeout = 4.0)
active_tasks = i.active()
reserved_tasks = i.reserved()
But still I get some connection errors.
Any ideas?
解决方案
推荐阅读
- python-3.x - 是否有另一种方法可以准确指定要选择哪些列或行进行预处理(清理数据框)?
- c - 如何在 C 中实现“which”命令?
- mysql - 如何从 ListView 中获取所选项目
- bean-io - 用于插入多种类类型的 Bean io
- python - 在某些情况下,python 中的默认 zip(a,b) 是否会切断最终元素?
- c# - c# WinForm直接下载不启动
- python - /invest/(?P1\d+)/ 处的 Django 错误 NoReverseMatch
- c# - 尝试从 API 获取数据时出错 - Blazor
- tensorflow - 使用对象检测 API 进行的训练未在 AI Platform 中的 GPU 上运行
- c - 如何比较C中的两个字符串?