Hi Liam,
There's no automatic way to cancel a function for a terminated workflow. But, long running functions can interrogate Resilient to determine if the workflow is still active or not. It's up to the function developer to add this logic.
We've added a helper routine to resilient_lib to facilitate this interrogation. It's resilient_lib.get_workflow_status(), which takes the workflow_id (passed to an executing function through the event object) and returns a data structure containing the workflow status. Here's what the logic would look like:
from resilient_lib import get_workflow_status
wf_instance_id = event.message["workflow_instance"]["workflow_instance_id"]
res_client = self.rest_client()
wf_status = get_workflow_status(res_client, wf_instance_id)
if wf_status.is_terminated:
yield StatusMessage('Workflow was terminated.')
------------------------------
Mark Scherfling
------------------------------