Vadym Dytyniak

04/05/2023, 10:24 AM
Hey @Marvin Can you tell me how to define on cancel handler?


04/05/2023, 10:24 AM
I think I can help you with that! The way to define a cancel handler in Prefect is to set the
flag to
when you are creating a flow, which will cause the flow run to be moved to the "Cancelling" state when cancellation is requested. From there, an agent then sends a signal to the infrastructure, requesting termination of the run. The handler will be called when the flow run enters the cancelling state and can be used to log or perform some other action before the run is moved to the "Cancelled" state. Flows can be cancelled from a variety of sources, including the command line, Prefect's user interface, the REST API, or the Python client. If you'd like to find out more, I suggest checking out the Prefect Docs on Flows and the PrefectHQ/prefect GitHub page. That should have all the information you need!