def read(self):
packet = self.packet<EOL>with self.__read_lock:<EOL><INDENT>buffer = self.__buffer<EOL>while len(buffer) < packet:<EOL><INDENT>buffer += self._read_data()<EOL><DEDENT>length = self.__unpack(buffer[:packet])[<NUM_LIT:0>] + packet<EOL>while len(buffer) < length:<EOL><INDENT>buffer += self._read_data()<EOL><DEDENT>term, self.__buffer = decode(buffer[packet:])<EOL><DEDENT>return term<EOL>
Read incoming message.