I’m trying to create a function that, when called, will extract information from an external source at irregular (and undefined) intervals. This data will then be placed in a database for later retrieval. I want this to be then running in the background even as other page requests are made. Is this possible?
I’m trying to create a function that, when called, will extract information from an
Share
The best way to run a Django function outside the request/response cycle is to implement it as a custom management command, which you can then set to run periodically using
cron.If you’re already using it,
celerysupports periodic tasks usingcelerybeat, but this requires configuring and running thecelerybeatdaemon, which can be a headache. Celery also supports long-running tasks (things started in a view, but completing in their own time), as described in your question title.