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

2010-07-07 Thread Hugh Emberson
On Thu, Jul 8, 2010 at 9:44 AM, Don Dwiggins wrote: >  On 7/5/2010 10:53 PM, Hugh Emberson wrote: >> 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.

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

2010-07-07 Thread Don Dwiggins
On 7/5/2010 10:53 PM, Hugh Emberson wrote: > 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

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

2010-07-05 Thread Hugh Emberson
On Tue, Jul 6, 2010 at 11:26 AM, Don Dwiggins 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

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

2010-07-05 Thread Don Dwiggins
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

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

2010-06-30 Thread Hugh Emberson
The way I do this is I isolate all the COM stuff in a separate thread from thread that runs my reactor. This thread starts by calling:     pythoncom.CoInitializeEx(pythoncom.COINIT_APARTMENTTHREADED) it then creates the COM object and runs an event loop something like this:     while keepRunnin

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

2010-06-29 Thread Don Dwiggins
Itamar, Thanks for the suggestions. The documentation of win32eventreactor sounds kind of scary, but still probably the best base to work from. I did some searching, and found Thomas Heller's win32guireactor at http://osdir.com/ml/python.twisted/2003-02/msg00190.html. I'm still naive enough a

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

2010-06-29 Thread Mark Wright
I'm sure you've already checked the simple things like this, but have you called CoInitialize() in your thread? If you're using the win32 extensions, it'll be called for you in the main thread, but any new thread needs to call it before attempting to do any COM work. On Mon, Jun 28, 2010 at 7:43

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

2010-06-28 Thread Itamar Turner-Trauring
On Mon, 2010-06-28 at 17:43 -0700, Don Dwiggins wrote: > What this probably means in practice is that twisted needs to use a > reactor which calls MsgWaitForMultipleObjects() and runs a message loop > when the function detects a new message is in the queue. I'm not sure > if there is an existi

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

2010-06-28 Thread Don Dwiggins
I need to create a COM object in a Windows application, and call it. Since the call will take some time to execute, I wrap it in a deferToThread. I've found that, when I create the object inline, it works. However, when I defer it, it hangs up in the win32com.client.Dispatch call. I've tried