I am wondering on how cancelation is handled in the case of a start_delay.
If I understand correctly if I send a cancelation to an actively running workflow it will add a WorkflowExecutionCancelRequested event and if I don’t handle it, the workflow won’t actually stop running.
But what happens in the case of a start_delay, do I still need to explicitly handle the WorkflowExecutionCancelRequested event?
can I get a code example of how cancelation is properly handled in a workflow?
The server will schedule a workflow task to dispatch the cancelation request. You can test it adding the delay here and run the example
If I understand correctly if I send a cancelation to an actively running workflow it will add a WorkflowExecutionCancelRequested event and if I don’t handle it, the workflow won’t actually stop running.
In Python if you handle the cancelation request (eg ignore the CancelledError thrown by the activity) the workflow won’t be cancelled
so it’s starting in the future. I changed my mind and I don’t want this workflow to run so I do later
await handle.cancel()
if the workflows doesn’t have a:
try:
...
except CancelledError as e:
cleanup()
then the workflow will not actually be canceled? is this also true with the start_delay=start_time - now(tz="UTC") above?
Also let’s say I do have a the try / except block in the workflow, when will the CancelledError be processed? like will the start_delay-ed workflow still be marked as running until the start time or will it immediately handle the exception?