def ignore_broken_pipe():
    """ If a shellish program has redirected stdio it is subject to erroneous
    "ignored" exceptions during the interpretor shutdown. This essentially
    beats the interpretor to the punch by closing them early and ignoring any
    broken pipe exceptions. """
    for f in sys.stdin, sys.stdout, sys.stderr:
        try:
            f.close()
        except BrokenPipeError:
            pass
def ignore_broken_pipe ( ) : for f in sys . stdin , sys . stdout , sys . stderr : try : f . close ( ) except BrokenPipeError : pass
If a shellish program has redirected stdio it is subject to erroneous
    "ignored" exceptions during the interpretor shutdown. This essentially
    beats the interpretor to the punch by closing them early and ignoring any
    broken pipe exceptions.