diff --git a/src/calibre/utils/logging.py b/src/calibre/utils/logging.py index 3175f301d9..a48b6cc523 100644 --- a/src/calibre/utils/logging.py +++ b/src/calibre/utils/logging.py @@ -31,7 +31,11 @@ class Stream(object): self._prints(text, end='') def flush(self): - self.stream.flush() + try: + self.stream.flush() + except BrokenPipeError: + # Don't make any fuss if we were logging to a pipe and it got closed + pass def prints(self, level, *args, **kwargs): self._prints(*args, **kwargs) @@ -61,9 +65,6 @@ class ANSIStream(Stream): with ColoredStream(self.stream, self.color[level]): self._prints(*args, **kwargs) - def flush(self): - self.stream.flush() - class FileStream(Stream): @@ -94,9 +95,6 @@ class HTMLStream(Stream): self._prints(*args, **kwargs) self._prints(self.normal, end='') - def flush(self): - self.stream.flush() - class UnicodeHTMLStream(HTMLStream):