3

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:

  1. Is it real "work" or peculiarity of Windows Task Manager?

  2. How one can avoid that. Maybe by using asyncio module or another way?

  3. Is it possible to process messages in another thread or asynchronously with pythoncom?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.