Thanks for the reply, Charlie.  The exceptions I was seeing were not related to Jython but rather to Jython trying to write to streams in my GUI console that I had mistakenly closed before exiting the interpreter.

I have another question however, now that I have my console going.  I am trying to implement a command history like you get in the standard Jython console (your basic up arrow and down arrow functionality).  It looks like you get this for free when you start a vanilla Jython console (if I run jython.bat for instance) but I can't find anywhere in the source that handles this.  How is this supported?  I see a class providing JLine support but I think this needs to be "turned on" with the JLine support jar being present as well.  How is the basic command history functionality provided in Jython (where is the code)?

Mark.
----------------------------------------------------------



"Charlie Groves" <charlie.groves@gmail.com>
Sent by: jython-users-bounces@lists.sourceforge.net

08/23/2007 03:46 AM

To
"Mark_Melvin@amis.com" <Mark_Melvin@amis.com>
cc
jython-users@lists.sourceforge.net
Subject
Re: [Jython-users] How To Programmatically Shut Down        InteractiveConsole





Hi Mark,

There's nothing special that needs to be done to shutdown the
interpreter.  Calling cleanup just calls the exit function as you
noted, and sys.exit does the same thing.  By default, exit_func is
None so nothing happens.  After you've called cleanup, you can let
garbage collection take its course.

What exceptions are you seeing when you close the streams?  What
streams are these that you close?

Charlie

On 8/22/07, Mark_Melvin@amis.com <Mark_Melvin@amis.com> 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.
>  ----------------------------------------------------------
>
>
>
>
>  Mark_Melvin@amis.com
> Sent by: jython-users-bounces@lists.sourceforge.net
>
> 08/22/2007 10:14 AM
>
> To jython-users@lists.sourceforge.net
>
> 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.
>  ----------------------------------------------------------
>
>
>
>  Mark_Melvin@amis.com
>  Sent by: jython-users-bounces@lists.sourceforge.net
>
> 08/22/2007 10:00 AM
>
>
> To jython-users@lists.sourceforge.net
>
> 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
> Jython-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jython-users
>
>

-------------------------------------------------------------------------
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
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users

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.