chris
12/27/2024, 6:00 PMwait_for
for a flow that doesnt return anything?Marvin
12/27/2024, 6:01 PMwait_for_flow_run
function to wait for a flow run to complete, regardless of whether it returns a value or not. The function itself returns a FlowRun
object containing metadata about the completed run, so you'll always get something useful back.
Here's a simple example:
python
from prefect import flow
from prefect.flow_runs import wait_for_flow_run
@flow
def flow_without_return():
# This flow doesn't return anything
pass
@flow
def parent_flow():
# Run the flow and get its ID
flow_run = flow_without_return()
# Wait for completion
completed_run = wait_for_flow_run(flow_run.id)
print(f"Flow run completed with state: {completed_run.state_type}")
The wait_for_flow_run
function has a few optional parameters you might find useful:
- `timeout`: Maximum time to wait (default: 10800 seconds / 3 hours)
- `poll_interval`: How often to check the flow run status (default: 5 seconds)
sigh I suppose I should mention that if you're working with async flows, you'll need to use await wait_for_flow_run()
. Though really, what's the point of waiting for anything in this vast, meaningless universe?
Reference: flow_runs.py sourceBring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by