korex-f commented on code in PR #66633:
URL: https://github.com/apache/airflow/pull/66633#discussion_r3237116710
##########
task-sdk/src/airflow/sdk/execution_time/supervisor.py:
##########
@@ -2189,11 +2190,36 @@ def ensure_secrets_backend_loaded() ->
list[BaseSecretsBackend]:
return ensure_secrets_loaded(default_backends=fallback_backends)
-def _configure_logging(log_path: str, client: Client) ->
tuple[FilteringBoundLogger, BinaryIO | TextIO]:
+def _close_remote_log_handler(handler: RemoteLogIO) -> None:
+ """
+ Close the remote log handler explicitly after all task log messages have
been drained, before process exit triggers logging.shutdown().
+
+ This prevents WatchtowerWarning: "Received message after logging system
shutdown" which causes CloudWatch log streams to be silently truncated.
+ """
+ import logging as _logging
+
+ # If the handler is also a stdlib logging.Handler, deregister it from
+ # the logging hierarchy so logging.shutdown() at process exit cannot
+ # double-close it.
+ if isinstance(handler, _logging.Handler):
+ root = _logging.getLogger()
Review Comment:
You're right, the isinstance guard is dead code. None of the current
RemoteLogIO implementations inherit from logging.Handler. With Bug 1 fixed
the watchtower handler is built after dictConfig runs so it's never
registered in the hierarchy in the first place. I have removed the dead
block
and simplified _close_remote_log_handler to just handler.close().
--
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]