[Twisted-Python] Creating a COM object in a thread

Hugh Emberson hugh.emberson at gmail.com
Tue Jul 6 01:53:12 EDT 2010


On Tue, Jul 6, 2010 at 11:26 AM, Don Dwiggins <ddwiggins at advpubtech.com> wrote:
> Hugh,
>> The way I do this is I isolate all the COM stuff in a separate thread
>> from thread that runs my reactor.
>
> This all looks good, and I think I understand it.  One question, though:
> from my investigation, it seems that the hangup is in the COM object
> creation itself, where Mark and I think it's waiting on a Windows
> message.  Wouldn't I have to have the event loop running before calling
> Dispatch?  (FWIW, I do call CoInitializeEx the same way you do, and have
> the object built with apartment threading.)

I got the order wrong.  On further reading of the code, the COM object
is created in response to a message from the Twisted thread, so at
that point the event loop has iterated at least once.

In my case the COM object is wrapped in a C++ wrapper that I don't
have the source for, so I don't know exactly what happens in there.
That C++ wrapper is then wrapped in a very thin python extension
module which doesn't do anything interesting.

> Thanks much for the help,

My pleasure.

Hugh



More information about the Twisted-Python mailing list