TransWikia.com

Good way to run ONE indefinite process on Django Framework

Stack Overflow Asked by kauii8 on February 8, 2021

I’m building a web app using a Django framework. There isn’t much user interaction with only a few static links, navbar, and a few plots which come from my app itself. The main part of the app comes from a python script which reads data from an external source, does some data processing on it, and then writes to my django database. Then after writing to the database a new page is created with information about the database entry. Note that there is no user interaction so no starting or stopping the task. I want the task to run in the background 24/7.

Thus far I’ve looked into celery and django-background-tasks. Celery seems like a bit much for my use case. I don’t think I need a broker service as I just want to run 1 task which the user will never interact with. Additionally, I don’t need multiple workers. Django-background-tasks seems like a good lightweight alternative but it seems it does not support indefinite tasks without having to refresh the task every once in a while (ideally I don’t want this). Is there a tool that is better suited for this use case? Or am I just completely misunderstanding celery and django-background-tasks.

Update
Thanks for the comments, everyone! So I looked up what was mentioned by @D Malan and I think a tool like Supervisord might fit my use case. That is I can run a python script separately from the django application in the background and then have the python script interact with the django application. The only problem I have now is getting the process to interact with the django app. @deceze mentioned invoking a manage command from the python script. So this would involve creating a subprocess from the python script calling a custom django management command which updates my database? Or can I use the django.core.management.call_command but from a python file separate from the django application. If this is the case how would it know where to get the command from?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP