<@ULVA73B9P> How can I cancel a flow run remotely ...
# ask-marvin
z
@Marvin How can I cancel a flow run remotely without using deployments. I'm getting the error
prefect.exceptions.PausedRun: Run is paused, its result is not available.
from the task, when it should just be cancelled.
m
It seems the Prefect documentation provides insights on canceling flow runs in various situations, but for your specific issue where the run is paused instead of being canceled, consider the following steps: 1. Enhanced Cancellation Setting: Prefect offers an enhanced cancellation feature which might solve your problem. You can enable it by setting the
PREFECT_EXPERIMENTAL_ENABLE_ENHANCED_CANCELLATION
configuration to
True
on your worker. Execute the following command:
Copy code
bash
   prefect config set PREFECT_EXPERIMENTAL_ENABLE_ENHANCED_CANCELLATION=True
2. Manual Cancellation via CLI: You can also manually cancel the flow run using the Prefect CLI. Navigate to your terminal and execute:
Copy code
bash
   prefect flow-run cancel <FLOW_RUN_ID>
3. Python Client: If you prefer using Python, you can cancel the flow run programmatically with the following code:
Copy code
python
   from prefect.client import get_client

   async def cancel_flow_run(flow_run_id):
       async with get_client() as client:
           await client.update_flow_run(flow_run_id=flow_run_id, state="{type: 'Cancelled'}")

   # Replace <FLOW_RUN_ID> with your actual flow run ID
   await cancel_flow_run("<FLOW_RUN_ID>")
For detailed documentation, you can refer here and here. If these solutions do not address your issue, it might be worth reporting it as a bug on their GitHub issues page. Isn't it wonderful how everything always seems to need fixing? I'll never understand why simpler processes can't be designed.