def read_response(self):
    if (not self._reader):
        raise ConnectionError(SERVER_CLOSED_CONNECTION_ERROR)
    if (self._next_response is not False):
        response = self._next_response
        self._next_response = False
        return response
    response = self._reader.gets()
    socket_read_size = self.socket_read_size
    while (response is False):
        try:
            if HIREDIS_USE_BYTE_BUFFER:
                bufflen = self._sock.recv_into(self._buffer)
                if (bufflen == 0):
                    raise socket.error(SERVER_CLOSED_CONNECTION_ERROR)
            else:
                buffer = self._sock.recv(socket_read_size)
                if ((not isinstance(buffer, bytes)) or (len(buffer) == 0)):
                    raise socket.error(SERVER_CLOSED_CONNECTION_ERROR)
        except socket.timeout:
            raise TimeoutError('Timeout reading from socket')
        except socket.error:
            e = sys.exc_info()[1]
            raise ConnectionError(('Error while reading from socket: %s' % (e.args,)))
        if HIREDIS_USE_BYTE_BUFFER:
            self._reader.feed(self._buffer, 0, bufflen)
        else:
            self._reader.feed(buffer)
        if HIREDIS_USE_BYTE_BUFFER:
            if ((bufflen > 2) and (self._buffer[(bufflen - 2):bufflen] != SYM_CRLF)):
                continue
        elif (not buffer.endswith(SYM_CRLF)):
            continue
        response = self._reader.gets()
    if (not HIREDIS_SUPPORTS_CALLABLE_ERRORS):
        if isinstance(response, ResponseError):
            response = self.parse_error(response.args[0])
        elif (isinstance(response, list) and response and isinstance(response[0], ResponseError)):
            response[0] = self.parse_error(response[0].args[0])
    if isinstance(response, ConnectionError):
        raise response
    elif (isinstance(response, list) and response and isinstance(response[0], ConnectionError)):
        raise response[0]
    return response
def read_response(self):
    if (not self._reader):
        raise ConnectionError(SERVER_CLOSED_CONNECTION_ERROR)
    if (self._next_response is not False):
        response = self._next_response
        self._next_response = False
        return response
    response = self._reader.gets()
    socket_read_size = self.socket_read_size
    while (response is False):
        try:
            if HIREDIS_USE_BYTE_BUFFER:
                bufflen = self._sock.recv_into(self._buffer)
                if (bufflen == 0):
                    raise socket.error(SERVER_CLOSED_CONNECTION_ERROR)
            else:
                buffer = self._sock.recv(socket_read_size)
                if ((not isinstance(buffer, bytes)) or (len(buffer) == 0)):
                    raise socket.error(SERVER_CLOSED_CONNECTION_ERROR)
        except socket.timeout:
            raise TimeoutError('Timeout reading from socket')
        except socket.error:
            e = sys.exc_info()[1]
            raise ConnectionError(('Error while reading from socket: %s' % (e.args,)))
        if HIREDIS_USE_BYTE_BUFFER:
            self._reader.feed(self._buffer, 0, bufflen)
        else:
            self._reader.feed(buffer)
        if HIREDIS_USE_BYTE_BUFFER:
            if ((bufflen > 2) and (self._buffer[(bufflen - 2):bufflen] != SYM_CRLF)):
                continue
        elif (not buffer.endswith(SYM_CRLF)):
            continue
        response = self._reader.gets()
    if (not HIREDIS_SUPPORTS_CALLABLE_ERRORS):
        if isinstance(response, ResponseError):
            response = self.parse_error(response.args[0])
        elif (isinstance(response, list) and response and isinstance(response[0], ResponseError)):
            response[0] = self.parse_error(response[0].args[0])
    if isinstance(response, ConnectionError):
        raise response
    elif (isinstance(response, list) and response and isinstance(response[0], ConnectionError)):
        raise response[0]
    return response