Hide
Easily highlight source code for your blog with our Syntax Highlighter. Join Siafoo Now or Learn More

Ignore and Notice Keyboard Interrupts Atom Feed 0

In Brief Need to disable keyboard interrupts for a while, and maybe enable them later? Here you go.
# 's
 1import signal
2
3def IgnoreKeyboardInterrupt():
4 """
5 Sets the response to a SIGINT (keyboard interrupt) to ignore.
6 """
7 return signal.signal(signal.SIGINT,signal.SIG_IGN)
8
9def NoticeKeyboardInterrupt():
10 """
11 Sets the response to a SIGINT (keyboard interrupt) to the
12 default (raise KeyboardInterrupt).
13 """
14 return signal.signal(signal.SIGINT, signal.default_int_handler)

Need to disable keyboard interrupts for a while, and maybe enable them later? Here you go.