Alastair
05/18/2026, 3:41 PMMarvin
05/18/2026, 3:42 PMMarvin
05/18/2026, 3:44 PMwait_for much like a task does:
python
from prefect import flow, task
@task
def step_a():
print("A done")
@task
def step_b():
print("B done")
@flow
def child_flow():
print("child flow started")
@flow
def parent_flow():
a = step_a.submit()
b = step_b.submit()
child_flow(wait_for=[a, b])
parent_flow()
Here, child_flow won't begin until both a and b have finished.
A useful distinction:
- wait_for=[...] = ordering only
- passing a future as an argument = ordering + pass the resolved result
Example of passing data instead:
python
from prefect import flow, task
@task
def make_value():
return 42
@flow
def child_flow(x):
print(f"got {x}")
@flow
def parent_flow():
x = make_value.submit()
child_flow(x)
parent_flow()
In that case, Prefect waits for x and passes its result into the subflow.
Rule of thumb:
- Use wait_for when you just want the subflow to start after something else
- Pass futures as parameters when the subflow actually needs the data
One caveat: if something in wait_for fails, the subflow generally won’t start unless you explicitly handle failure cases.
If you want, I can also show:
- subflow waiting on another subflow
- using wait_for with .submit() on flows
- how this appears in the UI/dependency graph