uranusjr commented on code in PR #32716:
URL: https://github.com/apache/airflow/pull/32716#discussion_r1269967131


##########
airflow/models/taskinstance.py:
##########
@@ -1601,7 +1596,8 @@ def _register_dataset_changes(self, *, session: Session) 
-> None:
                     session=session,
                 )
 
-    def _execute_task_with_callbacks(self, context, test_mode=False):
+    @provide_session
+    def _execute_task_with_callbacks(self, context, test_mode: bool = False, 
session: Session = NEW_SESSION):

Review Comment:
   ```suggestion
       def _execute_task_with_callbacks(self, context, test_mode: bool = False, 
*, session: Session):
   ```
   
   This is only ever called with an explicit session, no point decorating.



##########
airflow/models/taskinstance.py:
##########
@@ -1498,14 +1498,9 @@ def _run_raw_task(
         self.task = self.task.prepare_for_execution()
         context = self.get_template_context(ignore_param_exceptions=False)
 
-        # We lose previous state because it's changed in other process in 
LocalTaskJob.
-        # We could probably pass it through here though...
-        get_listener_manager().hook.on_task_instance_running(
-            previous_state=TaskInstanceState.QUEUED, task_instance=self, 
session=session
-        )
         try:
             if not mark_success:
-                self._execute_task_with_callbacks(context, test_mode)
+                self._execute_task_with_callbacks(context, test_mode, session)

Review Comment:
   ```suggestion
                   self._execute_task_with_callbacks(context, test_mode, 
session=session)
   ```



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