def close(self): ''' Send the quit message and close the socket ''' if self.socket is None: raise Error("Already closed") send_data = struct.pack('<i', 1) + int2byte(COM_QUIT) self.socket.sendall(send_data) self.socket.close() self.socket = None
def close(self): ''' Send the quit message and close the socket ''' if self.socket is None: raise Error("Already closed") send_data = b'\x01\x00\x00\x00' + int2byte(COMMAND.COM_QUIT) self.socket.sendall(send_data) self.socket.close() self.socket = None
def errorhandler(connection, cursor, errorclass, errorvalue): err = errorclass, errorvalue if cursor: cursor.messages.append(err) else: connection.messages.append(err) del cursor del connection if not issubclass(errorclass, Error): raise Error(errorclass, errorvalue) elif isinstance(errorvalue, errorclass): raise errorvalue else: raise errorclass(*errorvalue)