<@ULVA73B9P> is there a way to specify a `wait_for` for a flow that doesnt return anything?
c
@Marvin is there a way to specify a
wait_for
for a flow that doesnt return anything?
m
Based on my research, I can tell you that in Prefect 3.x, you can use the
wait_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:
Copy code
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 source