Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looping background process with django

I'm doing monitoring work with django. The program required to have a looping-forever sitting in background to process receiving data and update to database.

The job could be worked by writing a python script, and run in background with, for example, supervisord. However, I prefer the solution with django itself; that's the server process stay in a loop, listening for incoming packet.

Any suggestion would be high value and appreciate. Many thanks in advance.

like image 509
user1929999 Avatar asked Aug 01 '26 06:08

user1929999


2 Answers

In case you feel that Celery is a bit oversized for your needs you could also define a custom management command that lives forever and waits for your incoming packet.

like image 159
Jay Avatar answered Aug 04 '26 07:08

Jay


I suggest you to use Celery which works with Django and has support for long running tasks among other features.

http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html

http://docs.celeryproject.org/en/latest/getting-started/introduction.html

like image 32
Adrián Deccico Avatar answered Aug 04 '26 08:08

Adrián Deccico



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!