"""Closes the WebSocket connection."""
if self.client_terminated and self._waiting:
tornado.ioloop.IOLoop.instance().remove_timeout(self._waiting)
+ self._waiting = None
self.stream.close()
- else:
+ elif not self.stream.closed():
self.stream.write("\xff\x00")
self._waiting = tornado.ioloop.IOLoop.instance().add_timeout(
time.time() + 5, self._abort)
def close(self):
"""Closes the WebSocket connection."""
+ if self.stream.closed(): return
self._write_frame(True, 0x8, b(""))
self._started_closing_handshake = True
self._waiting = tornado.ioloop.IOLoop.instance().add_timeout(time.time() + 5, self._abort)