hooks could run as expected. But I cannot really get the
on_cancellation
hook to be triggered
imcom
07/30/2023, 4:23 AM
Here is how I handle the signal in my flow, I have this exception capture
imcom
07/30/2023, 4:23 AM
Copy code
except (asyncio.exceptions.CancelledError, prefect.exceptions.TerminationSignal):
# if the flow is cancelled, we should just do nothing here
# the caller is responsible for handling the state sync with camote and tortilla
# this is because the flow could be cancelled without even starting
log.warn(f"flow {task_id} is cancelled, terminate the processes")
return Cancelled(message=f"Cancelled: {task_id} is cancelled")
def _on_cancelled(flow, flow_run, state):
print(f"flow {flow_run.id} is {state}, deregister the service address")
print(f"flow run meta: {flow.dict()} {flow_run.dict()}")
print(f"flow run context: {prefect.context.get_run_context().dict()}")
imcom
07/30/2023, 4:24 AM
from what I've seen from the logs, the state change never triggered the
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.