Skip to content Skip to sidebar Skip to footer

Python Websocket With Tornado. Socket Aren't Closed

I'm a beginner with websocket, I'm trying to use tornado for that purpose. Here is my working code so far: from tornado import websocket from tornado import web import tornado.io

Solution 1:

You need to stop the server so that the port is available for use again.

This will stop the server:

tornado.ioloop.IOLoop.instance().stop()

You should call when you are done running the server (if you kill it with CTRL-C, you need to catch that and call this in the handler).

You can catch CTRL-C with this:

import signal
def signal_handler(signum, frame):
    tornado.ioloop.IOLoop.instance().stop()

signal.signal(signal.SIGINT, signal_handler)

Post a Comment for "Python Websocket With Tornado. Socket Aren't Closed"