PyFinalize problem from multiple DLLs - a possible work-around
Paul Miller
paul at fxtech.com
Sun Oct 20 10:55:59 EDT 2002
Hi folks. We're embedding Python and have come across a conflict when
multiple DLLs that link to Python are used. Here is the scenario:
Application
Extension1.dll
python22.dll
Extension2.dll
python22.dll
Although neither Extension knows about the other, they both link to
python, which seems to be sharing its global state between the two. This
causes problems when we do this:
Application Startup
Extension1_Startup
PyInitialize
Extension2_Startup
PyInitialize
Extension1_Shutdown
PyFinalize
Extension2_Shutdown
PyFinalize <--- oops
The first call to PyFinalize is cleaning everthing up, so the second
PyFinalize (or, Py_EndInterpreter) causes a critical exit error.
I think I have worked around the problem, however, by turning the static
initialized variable in pythonrun.c into a counter. PyInitialize
increments the counter, and initializes when it is 1. PyFinalize
decrements the counter, and cleans up when it reaches 0.
Can someone:
1. confirm this problem really exists
2. agree my solution probably fixes it (I have the code to proove it)
3. tell me where to submit the patch?
Thanks a lot!
More information about the Python-list
mailing list