Re: [python-win32] pythoncom.Pumpwaitingmessages() overloaded

2023-03-28 Thread Mark Hammond

On 29/03/2023 5:38 am, Philip Carr wrote:

Hi

Im looking for help on pythoncom.PumpWaitingMessages(). I’m using it to 
connect to a Windows application that has a com object to stream stock 
prices.


It works fine most of the time but when the rate of new events/messages 
gets too high ( unscientifically about 50 a second i think it can 
handle) it grinds to a halt and basically stops processing new 
events/messages and doesn't catch up even if the rate of new 
events/messages slows down. .


I can't explain why it doesn't recover, but you would certainly expect 
this to be quite slow given Python is executing an infinite loop.


Replacing the loop with just pythoncom.PumpMessages() also works, but I 
have no idea if this is more or less robust?


That should be more robust and performant in your scenario. The only 
time you should use PumpWaitingMessages is when that infinite loop isn't 
what you want.


HTH,

Mark

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


[python-win32] pythoncom.Pumpwaitingmessages() overloaded

2023-03-28 Thread Philip Carr
Hi



Im looking for help on pythoncom.PumpWaitingMessages(). I’m using it to
connect to a Windows application that has a com object to stream stock
prices.



It works fine most of the time but when the rate of new events/messages
gets too high ( unscientifically about 50 a second i think it can handle)
it grinds to a halt and basically stops processing new events/messages and
doesn't catch up even if the rate of new events/messages slows down. .



I'm using in my thread:


while True:

pythoncom.PumpWaitingMessages()



There's a few stackexchange questions with vague answers, I'd really
appreciate if someone could elaborate on some of these?



https://stackoverflow.com/questions/28352419/python-win32com-pumpwaitingmessages-processing



https://stackoverflow.com/questions/30691875/python-pythoncom-pumpmessages




Replacing the loop with just pythoncom.PumpMessages() also works, but I
have no idea if this is more or less robust?


I've seen plenty of examples with some time.sleep in the while True loop,
but that definitely doesnt work for my purposes.



Happy to share more code if it is needed for context, but the application
itself needs a paid subscription so it wouldn't be testable.


Thanks for your help


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