COM objects in threads

Toby Dickenson mbel44 at dial.pipex.net
Mon Feb 5 09:52:18 EST 2001


Mark Hammond <MarkH at ActiveState.com> wrote:

>The only other alternative is to use pythoncom.CoMarshalInterThreadInterfaceInStream and pythoncom.CoGetInterfaceAndReleaseStream to pass a COM object between 2 apartment-model threads.  The default is apartment-model threading.  COM says it is illegal to share objects between apartments, and as you have seen, often enforces it!

Also, you will need to run a message loop in *both* threads.

>You are going to have to find a reasonable reference on COM threading models, or see the "threading" appendix in "Python Programming on Win32" - that appendix was hell to write, and I am not going to attempt it again on Usenet ;-)  Deja threads (no pun intended;) on the subject may also help.

I can recommend this; its one of the best summaries around.

Toby Dickenson
tdickenson at geminidataloggers.com



More information about the Python-list mailing list