'Check if the server is alive'

def ping(self, reconnect=True):

    if (self._sock is None):
        if reconnect:
            self.connect()
            reconnect = False
        else:
            raise err.Error('Already    closed')
    try:
        self._execute_command(COMMAND.COM_PING, '')
        return self._read_ok_packet()
    except Exception:
        if reconnect:
            self.connect()
            return self.ping(False)
        else:
            raise
