Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a dashboard with all pending tasks using Celery?

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.

like image 726
e-satis Avatar asked Jul 28 '10 21:07

e-satis


2 Answers

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.

like image 77
David Avatar answered Oct 18 '22 20:10

David


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

Flower - Celery monitoring tool

like image 23
Manjit Kumar Avatar answered Oct 18 '22 20:10

Manjit Kumar