YingboWang commented on a change in pull request #5499:
URL: https://github.com/apache/airflow/pull/5499#discussion_r459801942



##########
File path: airflow/models/taskinstance.py
##########
@@ -1183,6 +1188,24 @@ def signal_handler(signum, frame):  # pylint: 
disable=unused-argument
         # Run on_execute callback
         self._run_execute_callback(context, task)
 
+        if task_copy.is_smart_sensor_compatible():
+            try:
+                # Must use task_copy instead of task otherwise no rendered 
value
+                if task_copy.register_in_sensor_service(self, context):
+                    self.log.info('Submitting %s to sensor service', self)
+                    self.state = State.SENSING
+                    self.start_date = timezone.utcnow()
+                    session.merge(self)
+                    session.commit()
+                    # Raise exception for sensing state
+                    raise AirflowSmartSensorException("Task successfully 
registered in smart sensor.")
+            except Exception as e:
+                if isinstance(e, AirflowSmartSensorException):
+                    raise e
+                self.log.warning("Failed to register in sensor service."
+                                 "Continue to run task in non smart sensor 
mode.")
+                self.log.exception(e, exc_info=True)
+

Review comment:
       Good point. Changed.




----------------------------------------------------------------
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.

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


Reply via email to