-
-
Save pitrou/e5a566e644730516b51de71145c5ea06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
import signal | |
import _thread | |
import threading | |
def noop_handler(signum, frame): | |
print("sig", signum) | |
def set_interrupts(signum): | |
while True: | |
signal.raise_signal(signum) | |
def cycle_handlers(signum): | |
for handler in itertools.cycle([noop_handler, | |
signal.SIG_IGN]): | |
signal.signal(signum, handler) | |
def main(): | |
signum = signal.SIGINT | |
signal.signal(signum, noop_handler) | |
t = threading.Thread(target=set_interrupts, args=(signum,), daemon=True) | |
t.start() | |
cycle_handlers(signum) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment