Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

persistant TCP connection in Django

I have a Django application which sometimes needs to send some data through TCP and I want this connection to be persistant.

The way I wanted to do it was to create a simple Twisted TCP server (I'm the one who will be waiting for the initial connection) and somehow call it from a Django view whenever I would be needing it.

How should the communication look like beetwen Twisted and Django in this case?

like image 988
virtuallight Avatar asked Oct 20 '25 03:10

virtuallight


1 Answers

Use the Twisted wsgi container to run Django. This container simply runs the WSGI application in multiple Twisted-threadpool threads, so you can simply call any Twisted API via blockingCallFromThread. There's really not that much to it!

like image 74
Glyph Avatar answered Oct 22 '25 17:10

Glyph