Message10915
We create PythonInterpreter instances by means of a custom InterpreterFactory.
This class contains the following map:
// Map with hard references to thread states, depending on their interpreter
private static final Map<PythonInterpreter, ThreadState> threadStates = new WeakHashMap<>();
Then the method InterpreterFactory.newInterpreter, before returning the created PythonInterpreter, stores the interpreter in the auxiliary map. Something like:
PySystemState sysState = new PySystemState();
PythonInterpreter pythonInterpreter = new PythonInterpreter(null, sysState);
ThreadState threadState = Py.getThreadState(sysState);
threadStates.put(pythonInterpreter, threadState);
This ensures that the ThreadState of the created PythonInterpreter is not garbage collected during the interpreter's lifetime, with the net effect that the appropriate PySystemState will be used for every interpreter.
This idea might somehow be implemented in the Jython core. |
|
Date |
User |
Action |
Args |
2016-08-25 13:26:26 | jsaiz | set | messageid: <1472131586.56.0.136546649565.issue2505@psf.upfronthosting.co.za> |
2016-08-25 13:26:26 | jsaiz | set | recipients:
+ jsaiz, zyasoft |
2016-08-25 13:26:26 | jsaiz | link | issue2505 messages |
2016-08-25 13:26:25 | jsaiz | create | |
|