My while loop does not exit when Ctrl+C is pressed. It seemingly ignores my KeyboardInterrupt exception. The loop portion looks like this:
while True:
try:
if subprocess_cnt <= max_subprocess:
try:
notifier.process_events()
if notifier.check_events():
notifier.read_events()
except KeyboardInterrupt:
notifier.stop()
break
else:
pass
except (KeyboardInterrupt, SystemExit):
print '\nkeyboardinterrupt found!'
print '\n...Program Stopped Manually!'
raise
Again, I'm not sure what the problem is but my terminal never even prints the two print alerts I have in my exception. Can someone help me figure this problem out?
except KeyboardInterruptcatches the exception. It won't be visible to the secondexcept (KeyboardInterrupt, SystemExit)if you don't re-raise it.raise KeyboardInterrupt()within the firstexcept KeyboardInterrupt:however I'm still experiencing the same issue.