Re: [python-win32] Dispatch command hangs

2019-08-15 Thread Tim Roberts
On Aug 15, 2019, at 9:28 PM, Joel Gross  wrote:
> 
> Yeah I'm calling CoInitialize. I can give CoInitializeEx a shot, but there's 
> no clear-cut way to set a priority for Dispatch? I'm not sure how these 
> objects are handled internally, is it just a regular queue?

Is this an out-of-process server, so you’re receiving requests from other 
processes?  If so, then I think you’re seeing RPC (Remote Procedure Call), 
which marshals the parameters back and forth, and I believe those are all 
first-come first-served.
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

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


Re: [python-win32] Dispatch command hangs

2019-08-15 Thread Joel Gross
Yeah I'm calling CoInitialize. I can give CoInitializeEx a shot, but
there's no clear-cut way to set a priority for Dispatch? I'm not sure how
these objects are handled internally, is it just a regular queue?

Thanks

On Thu, Aug 15, 2019 at 8:00 PM Tim Roberts  wrote:

> On Aug 14, 2019, at 6:12 PM, Joel Gross  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
>
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Dispatch command hangs

2019-08-15 Thread Tim Roberts
On Aug 14, 2019, at 6:12 PM, Joel Gross  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