ruediger.maehl at web.de
Tue Sep 10 03:47:43 EDT 2002
"Bob Easton" <bob at eleaston.com> wrote in
news:yz5e9.4237$rU2.145619 at news4.srv.hcvlny.cv.net:
> I have a script that can run, accessing network resources, for several
> days. Since the script does not normally need keyed input, exception
> processing does not raise the keyboard exception until after the
> program ends normally. I would like to be able to interrupt if from
> the keyboard, but have not learned the trick. How can I do this?
you are perhaps looking for this:
CONTROL_C = False
# clean up before exiting if necessary
print "Exiting application"
CONTROL_C = True
print "Interrupt caught! Please wait..."
# You must check CONTROL_C in your program
# optionally, if you need clean up actions
# do your task
print "Waiting for Control-C"
if CONTROL_C: break
More information about the Python-list