I use Python 3.4. I have a program that provide an integration with COM module in Windows, by win32com package. To process messages from this module I use the pythoncom.PumpWaitingMessages() method in the infinite while loop. But python infinite loop makes 100% CPU core load (as shown in Windows Task Manager). The questions:
Is it real "work" or peculiarity of Windows Task Manager?
How one can avoid that. Maybe by using asyncio module or another way?
pythoncom?PumpWaitingMessage will process messages and return as soon as there are no more messages to process.
You can call it in a loop, but you should call MsgWaitForMultipleObjects, or MsgWaitForMultipleObjectsEx, before the next loop iteration.
Avoid calling these functions before the initial loop iteration, as they'll block and you won't have a chance to see if some condition is met whether there are messages to process or not. Or alternatively, provide a reasonable timeout to these functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With