[python-win32] win32com.client.DispatchWithEvents free threading re-entrancy

Thomas Heller theller at ctypes.org
Thu May 10 19:52:14 CEST 2007


Richard Bell schrieb:
> I'm working on an application that does some IE automation via the COM
> interface.  I'm running in a free thread model,  sys.coint_flags = 0, and
> starting IE with
> win32.com.client.DispatchWIthEvents("InternetExplorer.Application",
> event_handler_class).  Events are arriving as revealed by print statements
> in the event handling routines.  Unfortunately, testing suggest that the
> event handling routines are being reentered (a win32 mutex can not be got
> because the event routines were reentered BEFORE it was released). 
> 

In a free-threaded apartment you must be prepared to receive events in different
threads.  So I think it is not forbidden that event handlers are reentered.

IMO this is most easily fixed by using an STA instead, if you can live with that.

Thomas



More information about the Python-win32 mailing list