def line_reader(self, file_descriptor, max_block_size=8 * 1024):
        r"""
        Decorator factory. The decorated callback is called once with
        every line (terminated by '\n') as they become available.
        
        Just like with `some_file.readline()`, the trailing newline character
        is included.
        
        The `max_block_size` paramater is just passed to `block_reader()`.
        """
        # line_reader could be implemeted with push_back_reader, but not doing
        # so allow us to only search new data for the newline chararcter.
        def decorator(callback):
            partial_line_fragments = []
            
            @self.block_reader(file_descriptor, max_block_size)
            def reader(data):
                # Loop since there could be more than one line in one block.
                while 1:
                    try:
                        end = data.index('\n')
                    except __HOLE__:
                        # no newline here
                        break
                    else:
                        end += 1 # include the newline char
                        partial_line_fragments.append(data[:end])
                        line = ''.join(partial_line_fragments)
                        partial_line_fragments[:] = []
                        callback(line)
                        data = data[end:]
                if data:
                    partial_line_fragments.append(data)
            return callback
        return decorator
dataset/ETHPy150Open SimonSapin/snippets/event_loop/event_loop.py/EventLoop.line_reader