如何使用 Celery 制作包含所有待处理任务的仪表板?

发布于 2024-09-12 08:48:51 字数 906 浏览 2 评论 0原文

我想要有一个地方可以观看所有待处理的任务。

我不是在谈论作为任务注册的函数/类,而是我可以显示的实际计划作业:名称、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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

许久 2024-09-19 08:48:51

看一下 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.

蓝海 2024-09-19 08:48:51

尝试 Flower - Celery 监控工具。
这提供了非常有用的仪表板来监控排队任务。

Flower - Celery 监控工具

Try Flower - Celery monitoring tool.
This provides really useful dashboard to monitor queued tasks.

Flower - Celery monitoring tool

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文