You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "korex-f (via GitHub)" <gi...@apache.org> on 2026/07/12 03:17:27 UTC
Re: [PR] Fix: CloudWatch/Watchtower logs dropped in Task SDK due to handler lifetime bugs [airflow]
korex-f commented on code in PR #66633:
URL: https://github.com/apache/airflow/pull/66633#discussion_r3565563440
##########
task-sdk/src/airflow/sdk/execution_time/supervisor.py:
##########
@@ -2385,11 +2382,31 @@ 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 from the subprocess pipe.
+
+ Called after process.wait() returns, before process exit triggers
+ logging.shutdown(). This ensures the remote handler's internal batch
+ queue is flushed before the process tears down. For example, the AWS
+ CloudWatch logger will emit:
+
+ WatchtowerWarning: "Received message after logging system shutdown"
+
+ if this is not done before process exit.
+ """
+ try:
+ handler.close()
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org