kaxil commented on code in PR #61627:
URL: https://github.com/apache/airflow/pull/61627#discussion_r3295434802


##########
task-sdk/src/airflow/sdk/execution_time/supervisor.py:
##########
@@ -2232,7 +2232,34 @@ def supervise_task(
                 sentry_integration=sentry_integration,
             )
 
-            exit_code = process.wait()
+            # Forward termination signals to the task subprocess so that the 
operator's
+            # on_kill() hook is invoked on graceful shutdown (e.g. K8s pod 
SIGTERM).
+            # Without this, the supervisor exits on SIGTERM without notifying 
the child,
+            # leaving spawned resources (pods, subprocesses, etc.) running.
+            prev_sigterm = signal.getsignal(signal.SIGTERM)

Review Comment:
   Re-flagging from prior review: `signal.signal()` returns the previous 
handler, so the separate `signal.getsignal()` calls are redundant.
   
   ```python
   prev_sigterm = signal.signal(signal.SIGTERM, _forward_signal)
   prev_sigint = signal.signal(signal.SIGINT, _forward_signal)
   ```
   
   Four lines collapse to two and you avoid the small race between the 
`getsignal()` lookup and the `signal()` install.



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