def METHOD_NAME(self):
    while True:
        # Try to extract a line from the buffer.
        offset = self._buffer.find(b'\n')
        if offset != -1:
            offset += 1 # include lf
            data =  self._buffer[:offset]
            del self._buffer[:offset]
            return data
        # Read a chunk and put in the buffer, then try again.
        while True:
            try:
                data = self.read()
            except socket.timeout:
                pass
            else:
                break
        self._buffer += data