Timeout & Waiting Strategy
TriggerFlow is event‑driven, so results may depend on external signals. Without timeouts, start() or get_result() can block indefinitely.
Why timeout matters
- Event‑driven: flows often wait for
emit()from outside - Async start:
execution.async_start()is non‑blocking; results may arrive later - Operational stability: timeouts prevent hung requests and enable fallback
For linear flows where all chunks are guaranteed to finish, you can set timeout=0 (return immediately) or timeout=None (wait forever).
How timeout works
start() / get_result() wait on the internal result_ready event:
timeout=None: wait forever untilend()orset_result()timeout=0: return immediately (usuallyNone)timeout>0: returnNoneand emit a timeout warning if not ready
Example: async trigger + timeout
python
from agently import TriggerFlow, TriggerFlowEventData
flow = TriggerFlow()
@flow.chunk
def approve(data: TriggerFlowEventData):
return f"approved:{data.value}"
flow.when("User.Confirm").to(approve).end()
execution = flow.start_execution("start", wait_for_result=False)
print("before", execution.get_result(timeout=0.01))
execution.emit("User.Confirm", "ok")
print("after", execution.get_result(timeout=1))Output (with a timeout warning once):
text
before None
after approved:okWhen timeout is not needed
- A linear chain with guaranteed
end() - You want to block until completion (
timeout=None)