pythonUser_07 wrote:
Is this the correct place to post a jython question?

I posted the following in the jython group, but I figured I'd post here
too:
_________________________________________
I am assuming that the PythonInterpreter environment is not a unique
environment from within a jvm.

Here is some pseudo code to show what I am talking about
1) create a jython module  file, lets call it "mytest"
   with a simple static class
   class simpleS:
      myVar = "test01"
2) Now set up two interpreter environments from within
   the same jvm
   PythonInterpreter py = new PythonInterpreter()
   PythonInterpreter py1 = new PythonInterpreter()
3) now in both interpreters, import the module
   py.exec("import mytest")
   py1.exec("import mytest")
   Now for both interpreters run
   "print mytest.simpleS.myVar"
4) Now for the crazy part.
   in the py interpreter run
   "mytest.simpleS.myVar = 'test02'
   in py1 look at the value
   "print mytest.simpleS.myVar"

Very interesting behavior.  So it seems that each python interpreter
instance does not act as its own seperate space.

My understanding is that the two PythonInterpreters wrap a single PySystemState which is where the modules are cached. So they share the same modules. If you want different behaviour you should give them each their own PySystemState.


Kent
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to