trapping keyboard interupt
Rob Hall
bloke at ii.net
Tue Oct 8 02:03:11 EDT 2002
Thanks guys.
As always, the group has provided me with info above and beyond what I
expected!
Excellent stuff.
Rob
Rob Hall <bloke at ii.net> wrote in message
news:3da1a909$0$26414 at echo-01.iinet.net.au...
> Having a bit of trouble trapping the keyboard interupt. I have something
> like this:
>
> continueFlag = 1
>
> try:
> while continueFlag:
> doSomeStuff
> except KeyboardInterrupt:
> continueFlag = 0
>
> doCleanUpOperations
>
> 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?
>
> Rob
>
>
More information about the Python-list
mailing list