[AIRFLOW-961] run onkill when SIGTERMed Closes #2138 from saguziel/aguziel-sigterm
Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/dacc69a5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/dacc69a5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/dacc69a5 Branch: refs/heads/v1-8-test Commit: dacc69a504cbfcdba5e2b24220fa1982637b17d3 Parents: dcc8ede Author: Alex Guziel <[email protected]> Authored: Sat Mar 11 10:43:49 2017 -0800 Committer: Bolke de Bruin <[email protected]> Committed: Sun Mar 12 08:34:09 2017 -0700 ---------------------------------------------------------------------- airflow/jobs.py | 8 ++++++++ 1 file changed, 8 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/dacc69a5/airflow/jobs.py ---------------------------------------------------------------------- diff --git a/airflow/jobs.py b/airflow/jobs.py index b6913f3..36548c2 100644 --- a/airflow/jobs.py +++ b/airflow/jobs.py @@ -2060,6 +2060,14 @@ class LocalTaskJob(BaseJob): def _execute(self): self.task_runner = get_task_runner(self) + + def signal_handler(signum, frame): + '''Setting kill signal handler''' + logging.error("Killing subprocess") + self.on_kill() + raise AirflowException("LocalTaskJob received SIGTERM signal") + signal.signal(signal.SIGTERM, signal_handler) + try: self.task_runner.start()
