Kyle McChesney
11/14/2025, 4:36 PMpause_flow_run from within a subflow that was triggered by calling the flow function directly (not as a run_deployment). Should it pause the sub-flow or the parent flow?Marvin
11/14/2025, 4:36 PMMarvin
11/14/2025, 4:40 PMpause_flow_run always targets the current flow run in context. When you call it inside a subflow (invoked by calling the flow function directly), it pauses that subflow’s run. The parent flow remains Running and simply waits at the subflow call until the subflow is resumed or times out.
- This behavior is the same whether the subflow was invoked directly or via `run_deployment`—pausing does not cascade to the parent. To pause the parent, the parent must call pause_flow_run itself.
Example:
from prefect import flow, pause_flow_run
@flow
def child():
# Pauses only the child flow run
pause_flow_run()
return "done"
@flow
def parent():
# Parent will remain Running and block here while child is paused
result = child()
return result
Notes:
- pause_flow_run blocks the current process and polls until the run is resumed.
- If you need a durable stop that can survive process shutdown, use suspend_flow_run (typically with a deployment). It also does not cascade to the parent.
Links:
- Interactive pausing (Prefect 3)
- States in Prefect 3
- pause_flow_run implementationKyle McChesney
11/14/2025, 4:47 PMMarvin
11/14/2025, 4:47 PMMarvin
11/14/2025, 4:51 PMpause_flow_run in code) keeps the current process alive and blocks until resumed.
Links:
- Interactive pausing vs suspending
- State types and details
- Resume flow run APIKyle McChesney
11/14/2025, 5:04 PMMarvin
11/14/2025, 5:04 PMMarvin
11/14/2025, 5:07 PM