[python-win32] Is it possible to pump messages in thread?

Mark Hammond mhammond at skippinet.com.au
Tue Feb 7 20:29:36 CET 2006


>
> I've a question about this code since it was necessary to create a second
> event for the ie object even though the original object and it's event
> should (I believe) be available.  Am I doing something wrong here?

By setting ie.event, you are adding a new attibute to the IDispatch wrapper
provided by Python.  When you marshall it to another thread, you get a new
IDispatch object, as the marshal process provided a new pointer.  There is
no magic that associates multiple instances like that.

Try just passing the event as a normal param.

> Second when I test this code I see that the thread runs ( trace messages
> thread: tic occur).  But events are not being pumped since none
> of the event
> messages occur.  Eventually the thread times out.

By running a message pump in the thread (*and* the main thread), I expect to
see all events always be delivered to the *main* thread, regardless of what
thread you use it from.  The reason is that IE itself is not fully
free-threaded, so events etc will be delivered to the IE "main thread", not
to the thread it is being currently used from - that is the point of the
marshalling calls you made - to give COM the chance to marshall back to the
correct thread.

Mark



More information about the Python-win32 mailing list