One solution is to use task queues. In Django it is easy to implement a task queue with a third-party library called "huey". It allows developers to specify when to execute a task using annotations:

def print_time():

This task would be executed every minute. Apart from scheduled tasks it also offers the option to execute tasks in the future.




Executing tasks regularly in a Django web application

Some web applications periodically need to perform some sort of task (retrieve data from a remote location, perform data store cleanup, etc.). Sometimes these tasks would take too long for a regular request and the user should not have to wait until the task completes.
Subscribe to Django