On Aug 14, 2019, at 6:12 PM, Joel Gross <jag...@gmail.com> wrote:

> I have a multi-threaded application that receives a large number of messages 
> (COM objects) in sudden bursts. During this time, I've noticed that if my 
> other thread attempts to create a new COM object via the Dispatch call, that 
> call seems to hang until the messages have been processed. This can take more 
> than a minute sometimes. 
> I am wondering if this is because the win32 side of things is still trying to 
> churn through all the messages? Is there a way to preempt this behavior to 
> ensure that the object I'm trying to create gets created immediately?
> 
This is a complicated topic.  Are you calling CoInitialize?  By default, that 
will create a “single-threaded apartment”, where actions get handled by a 
single thread.  You can try calling CoInitializeEx with COINIT_MULTITHREADED 
and see if that helps.

But even then, you bang up against the Python interpreter lock, which only 
allows the interpreter to handle one thread at a time.  I wouldn’t think you’d 
have to wait for the whole set of object requests to drain, but threading in 
Python is always tricky.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to