Event Objects

Events

  • A communication primitive for coordinating threads.
  • One thread signals an "event"
  • Other threads wait for it to happen.
     # Create an event object
     e = Event()
     
     # Signal the event
     def signal_event():
         e.set()
     
     # Wait for event
     def wait_for_event():
         e.wait()
     
     # Clear event
     def clear_event():
         e.clear()
  • Similar to a condition variable, but all threads waiting for event are awakened.
<<< O'Reilly OSCON 2000, Advanced Python Programming, Slide 78
July 17, 2000, beazley@cs.uchicago.edu
>>>