def read_response(self): response = self.read() if not response: raise ConnectionError("Socket closed on remote end") byte, response = response[0], response[1:] if MAJOR_VERSION >= 3: byte = unichr(byte) # server returned an error if byte == '-': if response.startswith('ERR '.encode()): response = response[4:] return ResponseError(response) if response.startswith('LOADING '.encode()): # If we're loading the dataset into memory, kill the socket # so we re-initialize (and re-SELECT) next time. raise ConnectionError("Redis is loading data into memory") # single value elif byte == '+': return response # int value elif byte == ':': return long(response) # bulk response elif byte == '$': length = int(response) if length == -1: return None response = self.read(length) #Start Modify By Sky response = str(response, encoding = "utf-8") #End Modify By Sky return response # multi-bulk response elif byte == '*': length = int(response) if length == -1: return None return [self.read_response() for i in xrange(length)] raise InvalidResponse("Protocol Error")