ephraimbuddy commented on issue #25297:
URL: https://github.com/apache/airflow/issues/25297#issuecomment-1439807739

   We can solve this by running the callback in the signal handler:
   ```diff
   diff --git a/airflow/models/taskinstance.py b/airflow/models/taskinstance.py
   index c74ff8b6b0..0c361d0d41 100644
   --- a/airflow/models/taskinstance.py
   +++ b/airflow/models/taskinstance.py
   @@ -1528,7 +1528,8 @@ class TaskInstance(Base, LoggingMixin):
                    return
                self.log.error("Received SIGTERM. Terminating subprocesses.")
                self.task.on_kill()
   -            raise AirflowException("Task received SIGTERM signal")
   +            if self.task.on_failure_callback:
   +                self._run_finished_callback(self.task.on_failure_callback, 
context, "on_failure")
    
            signal.signal(signal.SIGTERM, signal_handler)
   ```
   The raised exception is somehow lost and I think the loss is similar to the 
explanations in this blog: 
https://anonbadger.wordpress.com/2018/12/15/python-signal-handlers-and-exceptions/


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to