How to 'shut down' the InteractiveConsole?
David Charles <[email protected]>
| Newsgroups | gmane.comp.lang.jython.user |
|---|---|
| Message-ID | <CAJHoYyKnCDNGj8-zqkt6XH2KPQmh6KEQjpRJ4mYwZqmRrLB5qA@mail.gmail.com> |
Greetings Jythonistas,
I have a Jython program that runs and exit normally when I invoke it in
this way:
$ jython myprogram.py args
But runs to its end and _does_not_exit_ when I embed it inside of a *.jar
file and invoke it in this way:
$ java -classpath jar1:jar2:jar3 MainClass args
I must send a ctrl-C to stop my program when I run it in this way.
I have embedded the Jython interpreter in the following manner:
// Configure the Jython interpreter.
Properties preProps = PySystemState.getBaseProperties();
// preProps.put("python.cachedir.skip", false);
Properties postProps = new Properties();
postProps.put("python.cachedir.skip", false);
postProps.put("python.path", "");
PySystemState.initialize(preProps, postProps, appArgs);
// Start the Jython interpreter.
InteractiveConsole con = new InteractiveConsole();
// I found that for some reason, when running under java web start
// sys.prefix is None and the Lib directory under the jython.jar
// is not added to the sys.path automatically.
con.exec("import sys");
con.exec("sys.path.append(\"__pyclasspath__/Lib\")");
con.exec("sys.prefix = \"\"");
// Execute the application 'launch code' on the interpreter.
con.exec(appLaunchCode);
Other Jython programs, embedded in the same manner, do not exhibit this
problem. I suspect this application does something a little... different.
But, why then does my application exit normally when I run it on
$JYTHON_HOME/bin/jython?
Thanks,
David
------------------------------------------------------------------------------
_______________________________________________
Jython-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jython-users