Synchronization primitives: Event

This is one of the simplest mechanisms for communication between tasks: one task signals an event and other threads wait for it.

class evergreen.event.Event

This class implements a cooperative version of threading.Event.

is_set()

Returns True if the flag is set, False otherwise.

set()

Set the internal flag to true. All tasks waiting for it to become true are awakened. Tasks that call wait() once the flag is true will not block at all.

clear()

Reset the internal flag to false. Subsequently, tasks calling wait() will block until set() is called to set the internal flag to true again.

wait([timeout])

Block until the internal flag is true. If the internal flag is true on entry, return immediately. Otherwise, block until another task calls set() to set the flag to true, or until the optional timeout occurs. The internal flag is returned on exit.

Previous topic

Synchronization primitives: Channel

Next topic

Synchronization primitives: locks

This Page