utils.process: FDDrainer.flush() check stream is open

The method flush() in FDDrainer does not check the stream is open
before get its file descriptor, resulting in "ValueError: I/O operation
on closed file".

Changed flush() to check the stream is open, otherwise do not
try to flush.
Signed-off-by: NWainer dos Santos Moschetta <wainersm@redhat.com>
上级 557d0dfa
......@@ -418,7 +418,7 @@ class FDDrainer(object):
# and other logging handlers (custom ones?) also have
# the same interface, so let's try to use it if available
stream = getattr(handler, 'stream', None)
if stream is not None:
if (stream is not None) and (not stream.closed):
os.fsync(stream.fileno())
if hasattr(handler, 'close'):
handler.close()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册