Why doesn’t code like the following catch CTRL-C?
MAXVAL = 10000 STEP_INTERVAL = 10 for i in range(1, MAXVAL, STEP_INTERVAL): try: print str(i) except KeyboardInterrupt: break print 'done'
My expectation is — if CTRL-C is pressed while program is running, KeyboardInterrupt is supposed to leave the loop. It does not.
Any help on what I’m doing wrong?
Sounds like the program is done by the time control-c has been hit, but your operating system hasn’t finished showing you all the output. .