1. Orchestration
  2. Waits

A wait is a step that does nothing but wait. While a run waits, nothing is running and nothing is billed to a model. The run continues when the time comes or the event arrives.

@ava.workflow(input=Order)
def follow_up():
    sent = send_quote(ava.input)
    reply = sent >> ava.wait_for_event(Reply, key="customer-reply", timeout=timedelta(days=5))
    return reply >> handle_reply()
Rendering diagram…
WaitContinues when
ava.sleepA duration has passed, or a date is reached
ava.wait_for_eventAn event with a given key is sent to the run
ava.decisionA person decides

​
Sleep

ava.sleep(timedelta(hours=1))                       # for a duration
ava.sleep(until=datetime(2027, 1, 4, 9, tzinfo=UTC))  # until a date, with a timezone

​
Wait for an event

class Reply(ava.BaseModel):
    accepted: bool


reply = ava.wait_for_event(Reply, key="customer-reply", timeout=timedelta(days=5))
ArgumentMeaning
The model (Reply)The shape of the event’s data. It is checked when the event arrives.
keyThe name the sender uses. Unique in the workflow.
timeoutHow long to wait. None waits forever.

The next step receives the Reply, or None if the timeout passed first.

​
Send the event

ava event send RUN_ID customer-reply '{"accepted": true}' --idempotency-key reply-1

The idempotency key makes a repeated send harmless: the second one is ignored.

​
In the UI

A waiting run shows Waiting for time or event, and its timeline lists the wait under Pending.