def _getOutput()

in benchmarking/utils/subprocess_with_logger.py [0:0]


def _getOutput(ps, patterns, process_key=""):
    if not isinstance(patterns, list):
        patterns = [patterns]

    poller = select.poll()
    poller.register(ps.stdout)

    lines = []
    match = False
    while not getRunKilled(process_key):
        # Try to get output from binary if possible
        # If not possible then loop
        # and recheck run killed contidion
        if poller.poll(15.0):
            line = ps.stdout.readline()
        else:
            continue
        if not line:
            break
        nline = line.rstrip()
        try:
            # decode the string if decode exists
            decoded_line = nline.decode("utf-8", errors="replace")
            nline = decoded_line
        except Exception:
            pass
        lines.append(nline)
        for pattern in patterns:
            if pattern.match(nline):
                match = True
                break
        if match:
            break
    return lines, match