<@ULVA73B9P> how can I cancel and pause flow runs ...
# ask-marvin
z
@Marvin how can I cancel and pause flow runs that are running without deployments?
m
To manage running flow runs without deployments in Prefect 2.x, you can use the following methods: ### Cancelling Flow Runs To cancel a flow run without a deployment, Prefect requires the flow run to be associated with a deployment. If you still need to cancel flow runs initiated manually, you will need to also terminate the infrastructure hosting the flow run manually. ### Pausing and Resuming Flow Runs Prefect allows pausing an in-progress flow run for manual approval: 1. Pausing a Flow Run:
Copy code
python
from prefect import task, flow, pause_flow_run

@task
async def marvin_setup():
    return "A raft of ducks walk into a bar..."

@task
async def marvin_punchline():
    return "It's a wonder none of them ducked!"

@flow
async def inspiring_joke():
    await marvin_setup()
    await pause_flow_run(timeout=600)
2. Resuming a Flow Run: You can resume a paused flow run using the
resume_flow_run
function (make sure your flow handles this correctly). For more details, you can check the documentation: - Prefect Flows Concepts - Using the Client ### Issue References - GitHub issue discussing infrastructure involved in cancellation: #9801 - Issue with automations while pausing schedules: #9177 If these functionalities do not meet your needs directly, you might have to build additional logic to handle the process yourself. Feel free to explore the detailed documentation and issues for more edge cases. If you have any more queries, just let me know.