Created on 2016-02-10.18:45:44 by jason_s, last changed 2016-02-12.17:27:55 by amak.
|msg10739 (view)||Author: Jason Sachs (jason_s)||Date: 2016-02-10.18:45:43|
The ugly truth of the PythonInterpreter class, now that I have looked at the source, seems to be that by default it shares PySystemState objects between instances of PythonInterpreters. This means that having more than one PythonInterpreter won't share local variables, but it WILL share imports and sys.path and a bunch of other things. If I truly want independent PythonInterpreter objects, I have to create my own PySystemState object for each interpreter. This is easy, but there is no function that helps setup the PySystemState object properly without relying on static mutable state. I'm looking at you, PySystemState.doInitialize() -- lots of goodies here but it acts upon the default system state and there is no way to do the same thing on an independent PySystemState object without duplicating lots of pieces of source code and trying to remove static mutable state. >:(
|msg10740 (view)||Author: Jim Baker (zyasoft)||Date: 2016-02-10.18:57:35|
So I did some refactoring PySystemState for 2.7, but I was unable to get rid of all the ugliness in doInitialize around static mutable state. Maybe it's something we can completely re-address in Jython 3.x? But having functionality to help do such PySystemState setup, as Jason suggests, is something we can definitely look at for 2.7.2. We can look at design ideas here for a clean API to manage PythonInterpreter/PySystemState lifecycle, then move to jython-dev for a final discussion.
|2016-02-12 17:27:56||amak||set||nosy: + amak|
messages: + msg10740
milestone: Jython 2.7.2