import signal
import time
def sigint_handler(signum, frame):
print 'User pressed CTRL+C!'
signal.signal(signal.SIGINT, sigint_handler)
def main():
while True:
print 'Script to handle SIGINT'
time.sleep(2)
##########
if __name__ == "__main__":
main()
How can I block this below exception thrown by python itself when executing the code:
File "D:\Documents\scripts\ctrlc handler.py", line 19, in <module> main()
File "D:\Documents\scripts\ctrlc handler.py", line 14, in main
time.sleep(2) OError: [Errno 4] Interrupted function call