close

How to stop/kill Airflow tasks from the UI

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to stop/kill Airflow tasks from the UI in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to stop/kill Airflow tasks from the UI?

  1. How to stop/kill Airflow tasks from the UI?

    When the task is on running state you can click on CLEAR this will call job.kill() the task will be set to shut_down and moved to up_for_retry immediately hence it is stopped.

  2. stop/kill Airflow tasks from the UI

    When the task is on running state you can click on CLEAR this will call job.kill() the task will be set to shut_down and moved to up_for_retry immediately hence it is stopped.

Method 1

Simply set the task to failed state will stop the running task.

[2019-09-17 23:53:28,040] {logging_mixin.py:82} INFO - [2019-09-17 23:53:28,039] {jobs.py:2695} WARNING - State of this instance has been externally set to failed. Taking the poison pill.
[2019-09-17 23:53:28,041] {helpers.py:240} INFO - Sending Signals.SIGTERM to GPID 20977

Method 2

Pausing the Dag will not stop the task from being executed if the execution already started. However there is a way to stop a running task from the UI but it’s a bit hacky.

When the task is on running state you can click on CLEAR this will call job.kill() the task will be set to shut_down and moved to up_for_retry immediately hence it is stopped.

Clearly Airflow did not meant for you to clear tasks in Running state however since Airflow did not disable it either you can use it as I suggested. Airflow meant CLEAR to be used with failedup_for_retry etc… Maybe in the future the community will use this bug(?) and implement this as a functionality with “shut down task” button.

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read