Skip to content

First Of

Wait for the first of a set of events to complete.

FirstOf

Bases: Event

An Event that triggers when the first named child Event triggers.

The value of the FirstOf event is a (key, value) tuple identifying which child won and what its value was. All other child events are cancelled.

cancelled property

True if the event has been cancelled.

triggered property

True if the event has been triggered (not pending, not cancelled).

cancel()

Cancel the event.

Fires _on_cancel(old_value) regardless of whether the event was pending or already triggered. This ensures that resources consumed by a pre-triggered get event are restored when FirstOf discards it. Does nothing if the event is already cancelled.

fail(exc)

Trigger the event with an exception.

The process awaiting this event will re-raise exc.

succeed(value=None)

Trigger the event with value and notify all waiters.