ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> Jython-dev
Jython-dev
Re: [Jython-dev] System.exit() calls
by Samuele Pedroni other posts by this author
Nov 7 2003 2:37PM messages near this date
[Jython-dev] System.exit() calls | Re: [Jython-dev] New 'Projects Using Jython' page on wiki, was SARNavigator users Jython
At 23:22 26.10.2003 +0100, Robert Simmons wrote:

> As I was looking at the Jython code, I noticed that certain error 
> conditions can result in the Jython code calling System.exit(). This is 
> .... very bad. It would cause the application imbedding Jython to 
> spontaneously exit and potentially cause problems. Instead these calls 
> should throw RuntimeException or InternalError. This would accomplish the 
> same task of exiting the interpreter at these points while allowing the 
> developers imbedding the code to catch these exceptions and handle them 
> within their respective frameworks.

not all System.exits are equal:

- in 2.1 there was a System.exit triggered by OutOfMemoryError conditions, 
now it has been removed in the CVS , and there is code to convert it to a 
MemoryError PyException, probably a hook should also be added and code that 
condionatlly converts the MemoryError back to OutOfMemoryError if there are 
no futher Jython frames in a thread

- there are System.exits in the interpreter driver code, 
org.python.util.jython,
which are the right things

- there are some System.exits triggered by fatal conditions in 
initialization code run by the public static main(String[] args) of jythonc 
compiled main modules.

Then all the rest is code that in case of Python SystemExit exceptions 
(either raised directly or trough sys.exit() ) trigger a System.exit, given 
that we assume cooperative code this is most of the time the right thing.

Making that code throw some kind of new exception instead of calling 
System.exit would be the wrong thing, for example programs that call 
sys.exit() from the AWT thread will not work properly anymore.

The System.exit is triggered at Jython/Java boundaries when no further 
Jython frames
are present.

One either assumes that the jython code will not call sys.exit/raise SystemExit
or runs it trough jython code with

try:
   ...run code...
except SystemExit:
   ...

(or some more control could be added in terms of per-thread flags to 
disable the "conversion" and/or hooks... although sofar nobody has 
requested or thought of that).

regards. 



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Jython-dev mailing list
Jython-dev@[...].net
https://lists.sourceforge.net/lists/listinfo/jython-dev
Thread:
Robert Simmons
Samuele Pedroni

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved