Reputation: 375
I'm using django and I want a loop to run in the background let's say every 60 seconds. I found a plugin for Django which seems like it got what I need, but i'm not sure how to make it work. I understand you put the @background in, but as far as I understand django. This goes into a view right? But before the code is being loaded the first time, doesn't the webpage have to be loaded first?
I'm talking about the following plugin
https://django-background-tasks.readthedocs.io/en/latest/
Upvotes: 0
Views: 949
Reputation: 153
If you'd like to go in a new direction and if this is an asynchronous command that you are running periodically, consider using celery with module celery-beat.
Upvotes: 0
Reputation: 16495
Just to be clear:
pip install ...
, adding to INSTALLED_APPS
, running migrate
)@background
migrate
).python manage.py process_tasks
as a regular cron job; this will read the queue and execute the functions. As long as you don't call this, no function will be executed and queue will just keep filling.Does this answer your question? Or did I misunderstand you?
Upvotes: 1