I am developing an application in Django which uses REST API. The API request performs a long-running Celery canvas task(chain of tasks- saves the input to the database, performs computation, and then saves the computation result to the database). This long-running task depends on the user's input. Now, I want to add a functionality that facilitates the user with performing this long-running task at a specific time given by the user himself, so how can I do that?
i.e. Suppose, there are 2 users making the same API request with their own set of input parameters, and User 1 wants to schedule his task to be executed at 5:00 AM and user 2 at 7:30 AM. How can I achieve this?
Frontend: Angular
Backend: MySQL, Python (Django, Celery)
Any help in this regard will be highly appreciated.
You can schedule a celery task using apply_async
. You can pass a keyword argument named eta
to apply_async
, this is the exact time/date that the task will run.