call Python from a multithreaded DLL

Mark Hammond MarkH at
Thu Jul 5 21:25:03 EDT 2001

Alexandre Perrin wrote:

There are a few problems here.  One is that the code as it standard will 
almost certainly finalize Python before your thread has acquired the lock.

If you look at the Python for Win32 extensions source code 
( and find the 'pywintypes.h' 
file, you will find a 'CEnterLeavePython' class.  This manages the 
thread state for you and allows 'random' threads to call back into Python.


More information about the Python-list mailing list