LeonardoIshida commented on code in PR #57778:
URL: https://github.com/apache/airflow/pull/57778#discussion_r2535873774


##########
task-sdk/src/airflow/sdk/execution_time/supervisor.py:
##########
@@ -1097,6 +1104,45 @@ def _handle_process_overtime_if_needed(self):
             )
             self.kill(signal.SIGTERM, force=True)
 
+    def _check_task_timeout(self):
+        """
+        Check if task has exceeded execution_timeout and kill it if necessary.
+
+        This handles task timeout at the supervisor level rather than in the 
task
+        process itself.
+
+        The method implements signal escalation: SIGTERM -> SIGKILL if process 
doesn't exit.
+        """
+        # Only check timeout if we have a timeout set
+        if self._execution_timeout_seconds is None:
+            return
+
+        # Don't check timeout if task has already reached a terminal state
+        if self._terminal_state:
+            return
+
+        elapsed_time = time.monotonic() - self.start_time
+
+        if elapsed_time > self._execution_timeout_seconds:
+            log.error(
+                "Task execution timeout exceeded; terminating process",
+                timeout_seconds=self._execution_timeout_seconds,
+                elapsed_seconds=elapsed_time,
+                ti_id=self.id,
+                pid=self.pid,
+            )
+            self.process_log.error(
+                "Task execution timeout exceeded. Terminating process.",
+                timeout_seconds=self._execution_timeout_seconds,
+                elapsed_seconds=elapsed_time,
+            )
+
+            # Kill the process with signal escalation (SIGTERM -> SIGKILL)
+            self.kill(signal.SIGTERM, force=True)
+
+            self._terminal_state = TaskInstanceState.FAILED
+            self._task_end_time_monotonic = time.monotonic()

Review Comment:
   As far as I have looked, it does not



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