Nobody uses SystemRestart

Jeff Allen <[email protected]>
Newsgroups gmane.comp.lang.jython.devel
Message-ID <[email protected]>
I know this because it hasn't worked since 2014 and no-one has 
complained. Should we keep it?

First, some archaeology ... Restarting was introduced by Leo Soto in 
2008 (rationale here: https://codereview.appspot.com/2810) and is still 
marked as "experimental". Along the way it has had some work including 
the introduction of shutdownInterpreter() here: 
https://hg.python.org/jython/rev/94b5f009fb77#l3.36 and the accompanying 
socket._closeActiveSockets() that it calls. The motivation is to restart 
Jython when used in a web-server without incurring the application 
start-up time. Fast-forward to 2014 and _closeActiveSockets gets blown 
away (https://hg.python.org/jython/rev/107fe4a4c96b). From here on, 
raising SystemRestart gets you an NPE, but nobody notices that. Here it 
is in 2.7.0:

PS startup2> jython test_restart.py
Exception in thread "MainThread" java.lang.NullPointerException
         at org.python.util.jython.shutdownInterpreter(jython.java:439)
         at org.python.util.jython.run(jython.java:372)
         at org.python.util.jython.main(jython.java:142)

Restart gets a mention here: http://bugs.jython.org/issue1475 so it was 
used in 2.5.1 ...

I can keep it (really, restore it) but I'm not sure what to do to 
reproduce the missing _closeActiveSockets() or whether it matters. Just 
for now I've made the absence non-fatal while I work on the rest of 
http://bugs.jython.org/issue2686.

I think the idea of this has a couple of flaws we cannot easily get around.

  * It is not compatible with the idea of multiple interpreters
    (multiple sys modules). A restart, invoked by one interpreter, stops
    *all* Jython threads, cleans up *one* interpreter, and restarts the
    *whole* application.
  * Static initialisation is not reset unless you know to do it. Some
    static initialisation (the type system, loaded classes) is
    intentionally preserved because it drives the start-up time we're
    trying to save. But others (initially empty lists in sys, Options
    flags, the registry) can trip up the interpreter on a second pass.
    Every such case I find has an easy corrective: countless others are
    waiting to pounce.

Any thoughts on this experiment?

Jeff

-- 
Jeff Allen

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Jython-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jython-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.