Hi again,
On Tuesday, November 1, 2011 3:11:50 PM UTC+2, Alexander Koval wrote:
I have found that this doesn't really work for me. The reason is that I have some really fast tasks and one task that is always very time consuming. I have modified the code you linked so that there is only one lock, and when a task is started, it will sleep() until is able to acquire the lock.
I was satisfied with that until I realized that I can have the following situation:
Worker 1: really time consuming task
Worker 2: really time consuming task, sleeping waiting to acquire lock
Worker 3: really time consuming task, sleeping waiting to acquire lock
Worker 4: really time consuming task, sleeping waiting to acquire lock
From the point of view of celery, those four tasks are running, because celery doesn't care that 2, 3 and 4 are repeatedly calling time.sleep(5) until the lock is free.
But the problem with this solution is that all my fast running tasks are starved.
So I need something else.
Or create 2 queues (start one with concurency 1) and configure routes
to send that task to needed queue.
I have tried this, but I have some trouble with the configuration. I have added the following to my django settings:
CELERY_QUEUES = {"default" : {"exchange":"default", "binding_key":"default"},
"plate_solve": {"exchange":"plate_solve", "binding_key":"plate_solve"}
}
CELERY_DEFAULT_QUEUE = "default"
CELERY_ROUTES = {"astrobin.tasks.solve_image" : {"queue":"plate_solve", "routing_key":"solve_image"}}
The two queues are created, as I can read from the log, but the task astrobin.tasks.solve_image, destined to the plate_solve queue, is never executed.
I have tried changing the "routing_key" to "plate_solve" (same value as the binding_key) and all the tasks worked that way, but I was back at the problem above: the fast tasks were being starved by the slow ones.
Can you tell me where my config is wrong, and what else I'm doing wrong, please?
Thanks!
Salvatore.