- Orchestration
- Waits
Orchestration
Waits
Pause a run for an amount of time, or until something happens outside.
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…
| Wait | Continues when |
|---|---|
ava.sleep | A duration has passed, or a date is reached |
ava.wait_for_event | An event with a given key is sent to the run |
ava.decision | A 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))
| Argument | Meaning |
|---|---|
The model (Reply) | The shape of the event’s data. It is checked when the event arrives. |
key | The name the sender uses. Unique in the workflow. |
timeout | How 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.
