Graceful workflow cancellation handling from the cancelled workflow

Hello,

When a workflow is cancelled from the temporal UI, I would like to execute some handler code from the workflow that handles the cancellation gracefully.

Is it possible to add custom cancellation handler code to our workflows while using the python sdk?

Thanks!

Yes, you can have a finally or handle an exception via an except where temporalio.exceptions.is_cancelled_exception returns True

1 Like