Tri
11/01/2024, 9:26 PMon_cancellation
handler? I could cancel the flow in the UI, but the handler doesn't run
def on_cancellation(flow, run, state):
logger = get_run_logger()
<http://logger.info|logger.info>("cancellation handler running")
@task
def dummy_task():
while True:
sleep(1)
print("sleeping...")
@flow(on_cancellation=[on_cancellation], log_prints=True)
def test_console_flow():
dummy_task()
Bianca Hoch
11/01/2024, 9:45 PMfrom prefect import flow
from prefect.logging.loggers import flow_run_logger
import time
def log_something(flow, flow_run, state):
flow_run_logger(flow_run, flow).info(f"Hey there Tri, flow {flow.name} cancelled")
@flow(on_cancellation=[log_something])
def test_flow():
time.sleep(30)
return 42
if __name__=="__main__":
test_flow.serve(name="my-cancelled-flow")
Tri
11/02/2024, 1:58 AMprefect.flow_runs.worker - Process 43848 exited with status code: 3221225786; Process was terminated due to a Ctrl+C or Ctrl+Break signal. Typically, this is caused by manual cancellation.