Ejemplo n.º 1
0
 def close(self):
     if self.in_websocket_mode:
         try:
             self.websocket_handler.handle_websocket_close(self.websocket_connection_id)
         except Exception:
             self.log.exception('Error in WebSocket close handler')
         # Try to write a close frame, just once
         try:
             if self.send_buf is None and not self.ws_close_sent:
                 self.websocket_close(SHUTTING_DOWN, 'Shutting down')
                 with self.cf_lock:
                     self.write(self.control_frames.pop())
         except Exception:
             pass
         Connection.close(self)
     else:
         HTTPConnection.close(self)