ShubhamGondane commented on code in PR #63761:
URL: https://github.com/apache/airflow/pull/63761#discussion_r3068611887


##########
task-sdk/src/airflow/sdk/execution_time/supervisor.py:
##########
@@ -1164,6 +1169,27 @@ def _handle_process_overtime_if_needed(self):
             )
             self.kill(signal.SIGTERM, force=True)
 
+    def _handle_execution_timeout_if_needed(self):
+        """
+        Enforce execution_timeout from the supervisor as a safety net.
+
+        The primary timeout mechanism is SIGALRM in the task runner. This 
method
+        acts as a backup in case the child process loses its signal handler 
(e.g.,
+        after receiving SIGSEGV during DAG processing).
+        """
+        if self._execution_timeout_seconds is None or 
self._execution_start_monotonic is None:
+            return
+        if self._terminal_state:
+            return
+        elapsed = time.monotonic() - self._execution_start_monotonic
+        if elapsed > self._execution_timeout_seconds:
+            self.process_log.error(
+                "Execution timeout reached; supervisor terminating task 
process.",
+                timeout_seconds=self._execution_timeout_seconds,
+                elapsed_seconds=elapsed,
+            )
+            self.kill(signal.SIGTERM, force=True)

Review Comment:
   `_handle_execution_timeout_if_needed()` is only called inside the if alive: 
block (line 1147). alive is True only when `_service_subprocess()` returns 
None, which only happens while the process is still running so this method is 
never reached during the socket-drain phase. No guard needed.



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