This was accidentally added originally as a "Feature Request." Please delete Feature Request 3119739.
This is complicated and has taken me several weeks and many hours to track down to a SWIG issue. Attached is a tar.gz file with commented code that reproduces the problem and a detailed README.txt file.
The issue is related to running Python in an embedded manner using multiple threads with multiple calls to Py_NewInterpreter/Py_EndInterpreter. The first time a call to Py_EndInterpreter is executed the SWIG modules in other interpreters become completely invalid. This seems to even be the case for the *.py generated proxies. I've been baffled by what's going on but I managed to do the following things:
1) Reproduce the problem with a test case with minimal code (attached).
2) Verify it is not a Python bug by running this test case compiled as either a SWIG project OR with a hand coded python bridge. The handcoded python bridge works. The SWIG generated code does not.
Please see the README.txt file in the attached for more details.
This sample is meant to run on Linux and will run against SWIG 2.0.1. I have not tested it against an earlier release.