waiting for event from COM object

Mark Hammond mhammond at skippinet.com.au
Fri May 3 21:27:16 EDT 2002


Miranda Evans wrote:
> Attempting to write Python script that:
>  - is not a GUI application
>  - communicates with a COM object 
> 
> The COM object provides:
>  - a send method
>  - a MessageReceived event

This isn't really a COM object - pretend it was a pure-Python problem 
implemented using threads.

A good way is often to use the threading.Event() object.  You code then 
looks something like:

event = threading.Event()

class exampleEvents:
    OnMessageReceived(self):
        event.set()

# mainline.
sampobj.send("sample transmission")
event.wait(60)

if event.isSet():
   print "message recieved"
else:
   print "timeout"

Mark.




More information about the Python-list mailing list