Skip to content

Commit

Permalink
StreamLogWriter: Provide (no-op) close method. (#10884)
Browse files Browse the repository at this point in the history
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 <ash_github@firemirror.com>
  • Loading branch information
mjpieters and ashb authored Oct 20, 2020
1 parent 3ee6186 commit 26ae8e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions airflow/utils/log/logging_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ def __init__(self, logger, level):
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
"""
Expand Down
7 changes: 7 additions & 0 deletions tests/utils/test_logging_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,10 @@ def test_encoding(self):

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

0 comments on commit 26ae8e9

Please sign in to comment.