If you use win32 objects, then just call WFMO yourself. (See below.)
 
Of course, you won't be able to wait on a python thread(ing)
object, unless there was a call like Threading.GetOSObject()
or something. (I wish there was such a call for threads, files, events, etc.,
that way you could write "mostly portable" code and use OS specific
stuff on the python objects if you wanted to.)
 
I don't think there's a pure-python way to do the same
in one call.
 
Why not use a Queue.Queue object and just have all the threads post results
there - your consumer thread can wait on (.get) or poll (.get_nowait) on the Queue
as necessary.
 
mike
 
------------------------------
 
    StopEvent = win32event.CreateEvent(None, 0, 0, None)
 
    rc = win32event.MsgWaitForMultipleObjects(
          (StopEvent,otherEvents...),    0, # wait all
           win32event.QS_ALLEVENTS, # type of input
           win32event.INFINITE)  
 
  if rc == win32event.WAIT_OBJECT_0:
   print "Got first event"
   break
  elif rc == win32event.WAIT_OBJECT_0+1:
   print "Got second event..."
   break
  elif rc == win32event.WAIT_TIMEOUT:
  else:
   raise RuntimeError, "unexpected win32wait return value"

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Matthew Sherborne
Sent: Wednesday, April 10, 2002 1:53 PM
To: [EMAIL PROTECTED]
Subject: Threading question

I'd like to do a "waitForMultipleObjects" but I can't find such a thing in python thread or threading modules.
 
I have one thread that loops waiting for any one of four other threads to give him information, and of course the main thread may notify him to stop looping and die.
 
So I've got an event object for each of the four threads and I want to wait for any one of them to become true.
 
I suppose I could use a single Condition object that each thread sets, but that doesn't seem as efficient as waitfor multiple objects (from the win32api).
 
Is this something that Python needs? Is it easy to implement for different platforms? Is it there, but I haven't noticed it?
 
Any Ideas?
 
Thanks
Matthew Sherborne

Reply via email to