2

Is there any way to make Celery recheck if there are any tasks in the main queue ready to be started? Will the remote command add_consumer() do the job?

The reason: I am running several concurrent tasks, which spawn multiple sub-processes. When the tasks are done, the sub-processes sometimes take a few seconds to finish, so because the concurrency limit is maxed out by sub-processes, a new task from the queue is never started. And because Celery does not check again when the sub-processes finish, the queue gets stalled with no active tasks. Therefore I want to add a periodical task that tells Celery to recheck the queue and and start the next task. How do I tell Celery this?

1 Answer 1

0

From the docs:

The add_consumer control command will tell one or more workers to start consuming from a queue. This operation is idempotent.

Yes, add_consumer does what you want. You could also combine that with a periodic task to "recheck the queue and start the next task" every so often (depending on your need)

Sign up to request clarification or add additional context in comments.

3 Comments

No downvotes. I just removed my upvote, as you don't actually answer my problem, but just confirms my suspicion that "it looks like add_consumer does" the job.
Fair enough, but how does this not answer your question? Your question as-written is: "will the remote command add_consumer() do the job?" The answer is "yes." Please clarify. :)
I need a definite answer from someone who actually tried and knows. The docs are vague, which is why I asked in the first place. "start consuming from a queue" can mean multiple things when that queue is already being consumed from, but it is just on pause because the concurrency limit has been reached.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.