def reader_thread_func(filename, filter_, real_stdout):
    """
    Sit there, reading lines from the pipe `filename`, sending those for which
    `filter_()` returns False to `real_stdout`
    """
    with fdopen(osopen(filename, O_NONBLOCK | O_RDONLY)) as fd:
        while True:
            rlist, _, _ = select([fd], [], [])
            
            line = fd.readline()
            if not line:
                break
                
            elif not filter_(line):
                real_stdout.write(line)

    Sit there, reading lines from the pipe `filename`, sending those for which
    `filter_()` returns False to `real_stdout`
    
recipes/Python/577083_POSIX_context_manager_temporarily_silence_or/recipe-577083.py