如何使用 Celery 制作包含所有待处理任务的仪表板?
我想要有一个地方可以观看所有待处理的任务。
我不是在谈论作为任务注册的函数/类,而是我可以显示的实际计划作业:名称、task_id、eta、worker 等。
使用 Celery 2.0.2 和 djcelery,我在文档。我尝试过:
from celery.task.control import inspect
def get_scheduled_tasks(nodes=None):
if nodes:
i = inspect(nodes)
else:
i = inspect()
scheduled_tasks = []
dump = i.scheduled()
if dump:
for worker, tasks in dump:
for task in tasks:
scheduled_task = {}
scheduled_task.update(task["request"])
del task["request"]
scheduled_task.update(task)
scheduled_task["worker"] = worker
scheduled_tasks.append(scheduled_task)
return scheduled_tasks
但它永远挂在 dump = i.scheduled()
上。
奇怪的是,否则一切正常。
使用 Ubuntu 10.04、django 1.0 和 virtualenv。
I want to have some place where I can watch all the pendings tasks.
I'm not talking about the registered functions/classes as tasks, but the actual scheduled jobs for which I could display: name, task_id, eta, worker, etc.
Using Celery 2.0.2 and djcelery, I found `inspect' in the documentation. I tried:
from celery.task.control import inspect
def get_scheduled_tasks(nodes=None):
if nodes:
i = inspect(nodes)
else:
i = inspect()
scheduled_tasks = []
dump = i.scheduled()
if dump:
for worker, tasks in dump:
for task in tasks:
scheduled_task = {}
scheduled_task.update(task["request"])
del task["request"]
scheduled_task.update(task)
scheduled_task["worker"] = worker
scheduled_tasks.append(scheduled_task)
return scheduled_tasks
But it hangs forever on dump = i.scheduled()
.
Strange, because otherwise everything works.
Using Ubuntu 10.04, django 1.0 and virtualenv.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看一下 celerymon,它运行一个显示所有计划任务的 Web 服务器。您必须使用 -E 标志运行 celery 来打开事件,这些事件将被放入您的队列并由 celerymon 守护进程拉出。
Take a look at celerymon which runs a web server that shows all scheduled tasks. You'll have to run celery with the -E flag to turn on events, which get put onto your queue and pulled off by the celerymon daemon.
尝试 Flower - Celery 监控工具。
这提供了非常有用的仪表板来监控排队任务。
Flower - Celery 监控工具
Try Flower - Celery monitoring tool.
This provides really useful dashboard to monitor queued tasks.
Flower - Celery monitoring tool