jedcunningham commented on code in PR #73249:
URL: https://github.com/apache/airflow/pull/73249#discussion_r4029884062


##########
task-sdk/src/airflow/sdk/execution_time/supervisor.py:
##########
@@ -1606,22 +1516,27 @@ def update_task_state_if_needed(self):
             )
 
     def _send_terminal_state_msg(
-        self, msg: SucceedTask | RetryTask | DeferTask | RescheduleTask | 
AwaitInputTask
+        self, msg: TaskState | SucceedTask | RetryTask | DeferTask | 
RescheduleTask | AwaitInputTask
     ) -> None:
-        # Capture the message BEFORE the API call so the recovery dispatcher
-        # in `update_task_state_if_needed` can re-issue it if the call raises
-        # (network blip, transient server 5xx). Clear the pending slot and
-        # record the resulting state only after the call returns successfully.
+        if self._terminal_state == SERVER_TERMINATED:
+            return
+        self._terminal_state = msg.state
         self._pending_terminal_state_msg = msg
-        if isinstance(msg, SucceedTask):
+        if isinstance(msg, TaskState):
+            self.client.task_instances.finish(
+                id=self.id,
+                state=self.final_state,

Review Comment:
   Should this be msg.state instead? I think we have a gap where 
on_failure_callback or listeners timing out would blow this up, as it can't 
take up_for_retry and this doesn't pass through STATES_SENT_DIRECTLY like it 
was before. test_task_state_waits_for_exit_and_keeps_heartbeating needs some 
updates to cover this too.



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