From: Jim B. <jim...@py...> - 2018-09-04 21:53:20
|
Jeff, My first thought here is as follows: If there's no breaking test, then the feature was not implemented. I say this of course as the person who inadvertently nuked it :) The rest of the problems you raise are also highly fatal to resurrecting this feature. So I would suggest that you please do not restore. - Jim On Tue, Sep 4, 2018 at 1:55 PM, Jeff Allen <ja...@fa...> wrote: > 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 > > |