[Tutor] Nondestructive interrupting
John Brawley
jgbrawley@earthlink.net
Tue, 3 Apr 2001 17:45:03 -0500
Hello, all; newbie here.
I've got a script that runs endlessly (on purpose).
It creates a spherical region of space and starts moving points in the
space around, and is intended to run forever.
However, in the process of fine-tuning it, I need to be able to stop it
(without raising an error or exception, as happens now when I stop it
with a ctrl-C), and then do "one more thing."
There are reasons why I can't do this last thing inside the main part
ofthe script, and reasons why I can't do it after the script has
terminated with the keyboard interruption (ctrl-C).
I tried to use msvcrt --from sys.platform, but it won't work for me
(and I'd rather not use Win-Doze-specific in the Python).
All I want to do is insert a "watchdog" line in the main body of the
script, which repeatedly checks to see if a key has been pressed (_any_
key, although a specific key would be fine also), and then does this
last thing and terminates the script.
_Why_ I can't find such a simple thing in any of the Python docs,
manuals, tutorials, at python.org, or anywhere else, frazzles me; it
ought to be an obvious and basic function....
Can anyone tell me?
Thanks
JB
jgbrawley@earthlink.net
Web: http://www.jcn1.com/jbrawley
http://home.earthlink.net/~jgbrawley