def parse_session_failure(lines):
    def get_traceback(lines):
        """ Iterates  on traceback block found in lines.  """
        traceback = []
        for line in lines:
            traceback.append(line)
            if line == '':
                yield traceback
                traceback = []
        yield traceback

    tracebacks = list(get_traceback(lines))

    # Note: It is possible for a session failure to output a sequence of
    # tracebacks. In all scenarios, parse only the last one because it is the
    # error origin.
    last_traceback = iter(tracebacks[-1])

    return list(
        chain(
            chain(*tracebacks[:-1]),
            parse_traceback(last_traceback),
            last_traceback,  # Note: `parse_traceback` may have not fully consumed the iterator
        ),
    )
Parse the output when *pytest* failed to start a session. One or more
dataset/ETHPy150Open okcompute/vim-python-tests-runner/compiler/runners/pytest.py/parse_session_failure