Django thread for opc ua/ modbus connection

In the general case, no, you do not want to try and manage threads within your Django instance.

Basically, my general principle is that “you” don’t control the Django process. The wsgi container (uwsgi, gunicorn, etc) is in control. I always recommend against starting any kind of thread or process from within Django itself - there are too many ways that things can go wrong because you’re not in charge of the base process.)

My standard recommendation is to set up an external process to handle communications with external devices, then use some form of IPC to manage the communications between the two.

For more thoughts on this see the threads at: