win32com: passing object to threads

Mark Hammond MarkH at ActiveState.com
Thu Feb 1 18:21:39 EST 2001


Markus von Ehr wrote:


 > I know that I have to use the: pythoncom.CoInitialize() and
 > pythoncom.CoUninitialize()  in a way, but don't know
 > why.   Can anybody help me?

COM has different behaviour depending on the COM threading model.  This 
threading model is controlled by CoInitialize/CoInitializeEx(), hence 
you have to understand the different behaviours and make an appropriaate 
choice.  Just to scare you even more, if you pass objects between 
different "threading apartments", you have to use the scarily named 
pythoncom.CoMarshalInterThreadInterfaceInStream() to pass COM objects 
between threads.

The only reasonable documentation on this for Python is "Python 
Programming on Win32" (by me and Andy, published by OReilly.)  However, 
generic documentation on COM's threading models will also help.

Mark.




More information about the Python-list mailing list