# Django thread for opc ua/ modbus connection

**URL:** <https://forum.djangoproject.com/t/django-thread-for-opc-ua-modbus-connection/25275>\
**Category:** Getting Started\
**Created:** [November 13, 2023, 9:21am UTC](https://forum.djangoproject.com/t/django-thread-for-opc-ua-modbus-connection/25275 "2023-11-13T09:21:47Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [November 13, 2023, 12:24pm UTC](https://forum.djangoproject.com/t/django-thread-for-opc-ua-modbus-connection/25275/2 "2023-11-13T12:24:31Z")

</div>

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:

- [How to integrate GPIO input into django?](https://forum.djangoproject.com/t/how-to-integrate-gpio-input-into-django/15477)
- [Start another process with Django](https://forum.djangoproject.com/t/start-another-process-with-django/22176)
- [Message bus pattern in Django?](https://forum.djangoproject.com/t/message-bus-pattern-in-django/24806)

---

_[View the full topic](https://forum.djangoproject.com/t/django-thread-for-opc-ua-modbus-connection/25275)._
