From: Kevin J. B. <kev...@bi...> - 2002-05-24 20:40:02
|
Frank Cohen wrote: > I'd like to write into a Jython script a simple ability to stop a script > when a key is pressed. I want the script to be able to gracefully exit by > running a few last script commands. I haven't found anything that indicates > how to do this. Anyone want to point me in the right direction? You'll want to run the script in a separate thread, and code it in such a way that it either checks a termination flag periodically or is interruptable in another way. Your main thread can then watch for keyboard input, stop the script thread, do any desired cleanup, and terminate (gently or forcefully, as required). kb |