I have an issue using SWIG/Python with multiple instances of python interpreters.

Several (sub)-interpreters import the same SWIG-wrapped module. The first interpreter has access to the module functions. Everything is fine. When the second interpreter is created, (the first one is still alive, I just swap interpreter with function PyThreadState_Swap), the import directive for the module does not trigger the init function of the module as it has been loaded by the first interpreter.
The issue is that the second interpreter can access the symbols in the dictionary but the returned object are always NULL. Meaning for instance that calling a function will trigger an error.


Christophe Tornieri
Tech Lead, Software Architect Sub-sea division