jason810496 commented on code in PR #68779:
URL: https://github.com/apache/airflow/pull/68779#discussion_r3456706673


##########
providers/amazon/src/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py:
##########
@@ -151,20 +168,21 @@ def proc(logger: structlog.typing.WrappedLogger, 
method_name: str, event: struct
                 ct = created.timestamp()
                 record.created = ct
                 record.msecs = int((ct - int(ct)) * 1000) + 0.0  # Copied from 
stdlib logging
-            _handler.handle(record)
+            handler.handle(record)
             return event
 
         return (proc,)
 
     def close(self):
-        # Use the flush method to ensure all logs are sent to CloudWatch.
-        # Closing the handler sets `shutting_down` to True, which prevents any 
further logs from being sent.
-        # When `shutting_down` is True, means the logging system is in the 
process of shutting down,
-        # during which it attempts to flush the logs which are queued.
-        if self.handler is None or self.handler.shutting_down:
+        # Terminal flush — only ever called from upload(). Mark the IO closed 
first so `handler`
+        # stops rebuilding: a record arriving after teardown must be dropped, 
not revive a fresh
+        # handler. Read the cached handler directly so we never build one just 
to flush it.

Review Comment:
   Good point, I just updated both docstrings.



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