<@ULVA73B9P> - what is the expected behavior of ca...
# ask-marvin
k
@Marvin - what is the expected behavior of calling
pause_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?
m
thought for 248.8 seconds
Short answer: it pauses the subflow, not the parent. Details: -
pause_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:
Copy code
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 implementation
k
@Marvin does the suspend button in the UI pause the flow or suspend it and reschedule it as a new run?
m
thought for 206.4 seconds
Suspend in the UI suspends the run (it does not “pause-in-place”). - The UI action sets the run to Suspended (a Paused state with reschedule=True), ends the current execution so the worker/infrastructure can shut down, and queues the same flow run to be picked up again when you resume it. It does not create a new flow run ID. - By contrast, a “pause” (via
pause_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 API
k
@Marvin if I have a parent flow which is currently running a sub-flow, and I suspend the parent flow in the UI, what will happen to the sub-flow?
m
thought for 186.1 seconds
Short answer: the sub-flow keeps running. Details: - Clicking Suspend on the parent sets the parent to Suspended (reschedule) and stops its current execution. It does not cascade to subflows. - The child subflow is its own flow run and continues unaffected to completion or failure unless you cancel it explicitly. - Only a Cancel on the parent will cascade and stop running child subflows; Suspend does not. References: - Pausing vs suspending (interactive workflows) - Cancellation behavior and cascading to subflows - States in Prefect (Paused/Suspended)