Im adding a websocket server to my app so it can communicate with a web-based version of itself. For this I am using eventlet.
The problem i am running in to is once I start the server, I cannot get it to die. Even if i close my application, the process remains running in the background while the server stays alive. I have been googling and testing random things for days now and just cannot get this to happen. Im hoping someone here can help me.
Currently, i have a singleton class with a function that starts the listening:
def run_server(self, addr, port):
eventlet.wsgi.server(eventlet.listen((addr, port)), self.APP)
and for info, the app is:
socketio.WSGIApp(SIO, static_files={'/': {'content_type': 'text/html',
'filename': 'index.html'}})
and then I am starting this server on a thread in the app:
def run_on_thread(addr, port):
obj = WebSocket()
t = threading.Thread(target=obj.run_server, args=(addr, port))
t.setDaemon(True)
return obj, t
The thread gets started in my application, and as mentioned - everything works fine. All my messages are sent and received.
But nothing I can find will kill this server until i End Task on the python process.