Answer the question
In order to leave comments, you need to log in
celery. Running a Single Task Sequentially
The project describes methods that run as a celery task. like this: my_function.delay() and are executed somewhere in the background.
There is one task out of all tasks that needs to be executed only one at a certain time.
How to do it?
i.e. if the task is already running, then the next one (with the same name) must wait, then it will start. Let the other tasks continue to run in parallel with each other.
Answer the question
In order to leave comments, you need to log in
Read more about routing. It is necessary to send these tasks to a separate queue and configure only one worker that processes this queue, and allow only one thread in it. This is the only way if you only want to use celery.
If you still need reliability, you need a third-party implementation of a multi-machine lock, perform the task under it. Also, as in the first case, it is better to set up a separate queue but with several workers.
If you are using uWSGI. As an alternative (I don’t guarantee that everything will be smooth, I haven’t tried it myself), but you can experiment: refuse the selary and use the built-in uwsgi mechanisms using the spool and lock decorators projects.unbit.it/uwsgi/wiki/Decorators . If you decide to try it, please write about the results, and what restrictions and problems you encountered.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question