Re: [python-win32] Dispatch command hangs

2019-08-16 Thread Joel Gross
Yeah that's exactly it, there's a separate application running that is
delivering COM objects to my python script. Each object is its own callback
which requires a Dispatch call to get access to the properties. This can be
several thousand in a very short period of time and while this happens my
other thread will attempt to create a COM object and seems to hang on the
Dispatch call. During very high loads, the 2nd thread that is trying to
create a new object can hang for almost a minute.

On Thu, Aug 15, 2019 at 10:21 PM Tim Roberts  wrote:

> 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
>
___
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


[python-win32] Dispatch command hangs

2019-08-14 Thread Joel Gross
Hi,

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?

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