def robust_line_iter(istream):
    "Read lines, continuing if a blocking system call gets interrupted."
    tries_since_success = 0
    sub = _color_pattern.sub

    lines = unbuffered_lines(istream)
    while True:
        try:
            l = next(lines)
            tries_since_success = 0

            # trim and remove shell colors
            l_no_color = sub(u'', l.rstrip())

            yield l_no_color

        except __HOLE__:
            break

        except IOError:
            # sometimes we can get interrupted on a blocking read
            # let's retry a few times
            tries_since_success += 1

            if tries_since_success >= MAX_IO_RETRIES:
                # something's really wrong
                break
dataset/ETHPy150Open larsyencken/anytop/anytop/common.py/robust_line_iter