def suppress_interrupt():
    """Suppress KeyboardInterrupt exceptions while the context is active.
    
    The suppressed interrupt (if any) is raised when the context is exited.
    """
    interrupted = False

    def sigint_handler(signum, frame):
        nonlocal interrupted
        interrupted = True
    
    s = signal.signal(signal.SIGINT, sigint_handler)
    try:
        yield None
    finally:
        signal.signal(signal.SIGINT, s)
    if interrupted:
        raise KeyboardInterrupt()
def suppress_interrupt ( ) : interrupted = False def sigint_handler ( signum , frame ) : nonlocal interrupted interrupted = True s = signal . signal ( signal . SIGINT , sigint_handler ) try : yield None finally : signal . signal ( signal . SIGINT , s ) if interrupted : raise KeyboardInterrupt ( )
Suppress KeyboardInterrupt exceptions while the context is active.
    
    The suppressed interrupt (if any) is raised when the context is exited.