Pablo Martín Calvo
07/07/2025, 3:08 PMMarvin
07/07/2025, 3:08 PMMarvin
07/07/2025, 3:08 PMbash
prefect flow-run cancel <flow-run-id>
2. If the flow run remains stuck, you can force the state change using the Prefect CLI:
bash
prefect flow-run set-state <flow-run-id> cancelled
This will forcefully update the state in Prefect's database. However, be aware that:
- This only changes the state in Prefect's database
- Any actually running processes might continue running
- You may need to manually clean up any infrastructure (e.g., Docker containers, Kubernetes pods) if they're still running
For prevention:
- Ensure your infrastructure block configurations are correct and up-to-date
- When using containers, make sure they're configured to handle termination signals properly
- Consider implementing proper cleanup handlers in your flows using on_completion
or on_failure
parameters
You can find more details about flow run cancellation in the documentation.
Would you like me to provide more specific guidance based on your infrastructure setup (e.g., Docker, Kubernetes, etc.)?