You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by as...@apache.org on 2020/10/20 08:21:18 UTC

[airflow] branch master updated: StreamLogWriter: Provide (no-op) close method. (#10884)

This is an automated email from the ASF dual-hosted git repository.

ash pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/master by this push:
     new 26ae8e9  StreamLogWriter: Provide (no-op) close method. (#10884)
26ae8e9 is described below

commit 26ae8e93e8b8075105faec18dc2e6348fa9efc72
Author: Martijn Pieters <gi...@zopatista.com>
AuthorDate: Tue Oct 20 09:20:39 2020 +0100

    StreamLogWriter: Provide (no-op) close method. (#10884)
    
    Some contexts try to close their reference to the stderr stream at logging shutdown, this ensures these don't break.
    
    * Make pylint happy
    
    An explicit `pass` is better here, but the docstring _is_ a statement.
    
    Co-authored-by: Ash Berlin-Taylor <as...@firemirror.com>
---
 airflow/utils/log/logging_mixin.py | 7 +++++++
 tests/utils/test_logging_mixin.py  | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/airflow/utils/log/logging_mixin.py b/airflow/utils/log/logging_mixin.py
index 135691d..3b5f343 100644
--- a/airflow/utils/log/logging_mixin.py
+++ b/airflow/utils/log/logging_mixin.py
@@ -93,6 +93,13 @@ class StreamLogWriter:
         self.level = level
         self._buffer = ''
 
+    def close(self):
+        """
+        Provide close method, for compatibility with the io.IOBase interface.
+
+        This is a no-op method.
+        """
+
     @property
     def closed(self):   # noqa: D402
         """
diff --git a/tests/utils/test_logging_mixin.py b/tests/utils/test_logging_mixin.py
index b9550f4..7a6bda5 100644
--- a/tests/utils/test_logging_mixin.py
+++ b/tests/utils/test_logging_mixin.py
@@ -96,3 +96,10 @@ class TestStreamLogWriter(unittest.TestCase):
 
         log = StreamLogWriter(logger, 1)
         self.assertIsNone(log.encoding)
+
+    def test_iobase_compatibility(self):
+        log = StreamLogWriter(None, 1)
+
+        self.assertFalse(log.closed)
+        # has no specific effect
+        log.close()