def close(self): if self._sock is None: raise err.Error("Already closed") send_data = struct.pack('<iB', 1, COMMAND.COM_QUIT) try: self._write_bytes(send_data) except Exception: pass finally: self._sock.close()
def close(self): if self._close_callback and callable(self._close_callback): cb = self._close_callback self._close_callback = None cb() if self.socket is None: raise err.Error("Already closed") send_data = struct.pack('<iB', 1, COMMAND.COM_QUIT) try: self._write_bytes(send_data) except Exception: pass finally: sock = self.socket self.socket = None self._rfile = None sock.set_close_callback(None) sock.close()