Skip to main content

prefect.server.services.cancellation_cleanup

The CancellationCleanup service. Responsible for cancelling tasks and subflows that haven’t finished.

Functions

cancelling_timeout_check_key

cancelling_timeout_check_key(flow_run_id: UUID) -> str

schedule_cancelling_timeout_check

schedule_cancelling_timeout_check() -> None

maybe_schedule_cancelling_timeout_check_for_state

maybe_schedule_cancelling_timeout_check_for_state() -> None

cancel_child_task_runs

cancel_child_task_runs(flow_run_id: Annotated[UUID, Logged]) -> None
Cancel child task runs of a cancelled flow run (docket task).

cancel_subflow_run

cancel_subflow_run(subflow_run_id: Annotated[UUID, Logged]) -> None
Cancel a subflow run whose parent flow run was cancelled (docket task).

handle_cancelling_timeout

handle_cancelling_timeout(flow_run_id: Annotated[UUID, Logged], flow_run_state_id: Annotated[UUID, Logged], timeout_cancelled_state_id: Annotated[UUID, Logged]) -> CleanupQueueMessage | None
Handle a scheduled CANCELLING timeout check for a single flow run.

ensure_cancelling_timeout_checks

ensure_cancelling_timeout_checks(docket: Docket = CurrentDocket(), db: PrefectDBInterface = Depends(provide_database_interface), perpetual: Perpetual = Perpetual(automatic=True, every=datetime.timedelta(seconds=get_current_settings().server.services.cancellation_cleanup.loop_seconds))) -> None
Seed Docket timeout checks for flow runs already in CANCELLING.

monitor_cancelled_flow_runs

monitor_cancelled_flow_runs(docket: Docket = CurrentDocket(), db: PrefectDBInterface = Depends(provide_database_interface), perpetual: Perpetual = Perpetual(automatic=True, every=datetime.timedelta(seconds=get_current_settings().server.services.cancellation_cleanup.loop_seconds))) -> None
Monitor for cancelled flow runs and schedule child task cancellation.

monitor_subflow_runs

monitor_subflow_runs(docket: Docket = CurrentDocket(), db: PrefectDBInterface = Depends(provide_database_interface), perpetual: Perpetual = Perpetual(automatic=True, every=datetime.timedelta(seconds=get_current_settings().server.services.cancellation_cleanup.loop_seconds))) -> None
Monitor for subflow runs that need to be cancelled.