I'm trying to get celery to route tasks based on the name of the task ... basically, I have tasks called "worker.some_name" and "web.some_name", and I use two different queues, respectively, the work site and the website. I would like all work tasks to go into the work queue and vice versa. I currently have a large CELERY_ROUTES dictionary:
CELERY_ROUTES = { "web.some_name": { "queue": "web" }, "web.some_other_name": { "queue": "web" }, etc.... }
But I would like something more general:
CELERY_ROUTES = (MyRouter(), ) class MyRouter(object): def route_for_task(self, task, args=None, kwargs=None): if task.split('.')[0] == "worker": return {"queue": "worker"} return {"queue": "web"}
But this does not seem to work. Any ideas? Thanks.
source share