Prevent repeated flushing in TeeStream.
@@ -888,6 +888,7 @@ class TeeStream(BaseStream):
Flushes all registered consumer streams.
"""
for consumer in self.consumers:
+ if not getattr(consumer, "closed", False):
consumer.flush()
def _write(self, *args, **kwargs):
@@ -920,6 +921,7 @@ class FilteredStream(BaseStream):
"""
Flushes the consumer stream.
"""
+ if not getattr(self.stream, "closed", False):
self.stream.flush()
def _write(self, *args, **kwargs):
