From: <ast...@gm...> - 2007-08-23 02:19:50
|
I'm not sure what exactly you want, but you can "exit" from a Jython console this way: >> import sys >> sys.exit() On 8/22/07, Mar...@am... <Mar...@am...> wrote: > > > Sorry to keep replying to myself - but this is the best solution I have > found. Please feel free to suggest a better one! ;o) > > // Unhook the streams from the console > interp.setOut(System.*out*); > interp.setErr(System.*err*); > *try* { > interp.push("\n\n"); > interp.push("import sys"); > interp.push("sys.exit(0)"); > } *catch* (PyException exc) { > *if* (!Py.*matchException*(exc, Py.*SystemExit*)) { > *throw* exc; > } > } > interp = *null*; > > M. > ---------------------------------------------------------- > > > > *Mar...@am...* > Sent by: jyt...@li... > > 08/22/2007 10:14 AM > To > jyt...@li... cc > > Subject > Re: [Jython-users] How To Programmatically Shut Down > InteractiveConsole > > > > > > > > Ah. Simply unhooking the UI console streams from the InteractiveConsole > (setting them back to System.out and System.err) clears up my exceptions, > but I am not sure I am actually killing the interpreter. What is the > default exit function for PySystemState (called by cleanup())? Here is what > I am currently doing when I dispose my console (this is in a UI where the > user can open/close as many Jython consoles as they wish): > > interp.setOut(System.*out*); > interp.setErr(System.*err*); > interp.cleanup(); > interp = *null*; > > (interp is an instance of InteractiveConsole) > > M. > ---------------------------------------------------------- > > > *Mar...@am...* > Sent by: jyt...@li... > > 08/22/2007 10:00 AM > > To > jyt...@li... cc > > Subject > [Jython-users] How To Programmatically Shut Down InteractiveConsole > > > > > > > > > > Hi All, > > This seems like a silly question, but what is the recommended way of > programmatically shutting down an embedded InteractiveConsole if you cannot > send it a CTRL+Z from the keyboard? I want to be able to open and close > interpreters programmatically and I keep getting exceptions if I close the > streams. But I can't seem to find a way to send a shutdown signal the the > interpreter. Is there a way to do this that I am missing, or do I need to > subclass InteractiveInterpreter and make my own console that looks for a > certain event? > > Thanks, > Mark. > > > AMI Semiconductor - "Silicon Solutions for the Real World" > NOTICE: > This electronic message contains information that may be confidential or privileged. The information is intended for the use of the individual or entity named above. If you are not the intended recipient, please be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you received this electronic message in error, please notify the sender and delete the copy you received. > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > > |