def accept_no_intr(sock):
    """ Call sock.accept such that if it is interrupted by an EINTR
        ("Interrupted system call") signal or a KeyboardInterrupt exception, it
        is re-called.
    """
    while True:
        try:
            return sock.accept()
        except socket.error as err:
            if err.args[0] != EINTR:
                raise
        except KeyboardInterrupt:
            pass
dataset/ETHPy150Open enthought/envisage/envisage/plugins/remote_editor/communication/util.py/accept_no_intr/original