korex-f commented on code in PR #66633:
URL: https://github.com/apache/airflow/pull/66633#discussion_r3565598238
##########
task-sdk/src/airflow/sdk/execution_time/supervisor.py:
##########
@@ -2405,9 +2422,30 @@ def _configure_logging(log_path: str, client: Client) ->
tuple[FilteringBoundLog
with _remote_logging_conn(client):
processors = logging_processors(json_output=json_logs)
+
logger = structlog.wrap_logger(underlying_logger, processors=processors,
logger_name="task").bind()
- return logger, log_file_descriptor
+ try:
+ yield logger
+ finally:
+ # Flush and close the remote handler now — AFTER the supervisor has
+ # drained all task log messages from the subprocess pipe (i.e. after
+ # process.wait() has returned).
+ #
+ # Without this, the only thing that ever closes the handler is
+ # Python's logging.shutdown() at process exit, which fires after
+ # supervise_task() returns. Any messages still queued in the handler
+ # at that point are silently dropped. For example, the AWS CloudWatch
+ # logger will emit:
+
+ # WatchtowerWarning: "Received message after logging system shutdown"
+ remote_handler = load_remote_log_handler()
+ if remote_handler is not None:
Review Comment:
Applied suggestion. Thanks
--
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]