[python-win32] Pythonwin COM problem

Bielik, Robert Robert.Bielik at gyros.com
Thu Jun 16 08:47:14 CEST 2005


I have a module where I use COM to communicate with some HW drivers. In my module I use CoInitializeEx to init COM in multithreaded mode. However, when I use PythonWin to debug/test my module, I get an error due to the fact that PythonWin has (implicitly) initialized COM in apartment threaded mode. Subsequently, my module crashes Python.

How, when and where PythonWin initializes COM (apartment threaded) I don't know, but the fact is
it does do that since even if I remove my modules CoInitializeEx, COM works up to the point where a different thread uses a marshalled COM interface (CRASH!)

If I use my module via a .py script and run that directly, everything works fine!

So, how do I make sure PythonWin (implictly) inits COM in multithreaded mode?

TIA
/Rob
Ps. I've set the sys.coinit_flags (in localserver.py) to zero (value of COINIT_MULTITHREADED), recompiled it, but that didn't change anything...


More information about the Python-win32 mailing list