[python-win32] Strange message pump behavior

Sumeet Sobti sumeet_sobti at yahoo.com
Sat Mar 18 00:26:41 CET 2006


Hi,

I have a very simple, single-threaded COM client program. I use COM
objects created by a third-party software. I use win32com to do all
COM-related processing in my program.

In my program, I create a few COM objects, some of which are supposed
to periodically receive events. So, I have a message loop in my program
that uses pythoncom.PumpWaitingMessages() to pump messages, so the
events get fired whenever they arrive (usually every 1-3 seconds). I am
not using any GUI, Tk, or anything. It's a stand-alone command-line
program.

However, in one particular case, I see some strange behavior where the
message pump stops receiving any events for several minutes (sometimes
tens of minutes).

I have reduced the problem case to the following sequence of steps (the
problem is illustrated in the last step):

## begin

## 1
create_com_objects()
pump_messages_for_10_seconds() ## here events are received as expected

## 2
time.sleep(10)
pump_messages_for_10_seconds() ## here events are received as expected

## 3
time.sleep(10)
pump_messages_for_10_seconds() ## here events are received as expected

## 4
a_com_object.a_method()
pump_messages_for_10_seconds() ## here events are received as expected

## 5
a_com_object.a_method()
pump_messages_for_10_seconds() ## here events are received as expected

## 6 -- PROBLEM CASE
time.sleep(10)
a_com_object.a_method()
pump_messages_for_1000_seconds() ## PROBLEM: NO EVENTS RECEIVED HERE

## end

The above behavior seems to be very repeatable.

(1) When my program sleeps or does something other than pumping
messages, aren't messages/events supposed to get queued somewhere? So,
when my program gets back to pumping, shouldn't it be able to pump the
events that arrived while it was sleeping or doing other stuff?

(2) The problem seems to be triggered when I invoke one particular
method on one particular object in one particular way *immediately*
after waking up from sleep (like in step 6 above). However, the problem
doesn't occur in steps 4 and 5 where I invoke the same method in the
exact same way as I do in step 6.

(Steps 2,3,4,5 can be rearranged, deleted, executed multiple times,
etc. without affecting the appearance of the problem in the last step.)

Any ideas what could be causing this behavior?

Is it at all possible that an incorrect implementation of the COM
object is messing up with the messages/events in my client program?

I'd really appreciate any help/ideas. Thanks!

-Sumeet.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Python-win32 mailing list