trapping keyboard interupt

Rob Hall bloke at
Mon Oct 7 17:32:54 CEST 2002

Having a bit of trouble trapping the keyboard interupt.  I have something
like this:

continueFlag = 1

    while continueFlag:
except KeyboardInterrupt:
    continueFlag = 0


Basically, I have a program that runs continuously.  Sometimes I need to
terminate the program, save its state, and restart it at a later time.
However,  In it, I have a long process that can take 5 minutes to complete,
and once this process starts, i don't want it to stop.  But I would like it
to know that as soon as it has finnished this process it should terminate.

My intention was to trap the Keyboard Interupt, reset a flag that would tell
the program to exit the main loop.  But I can't figure how to resume
execution from the point I gave the Keyboard Interupt.

Can someone help?


More information about the Python-list mailing list