mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-01-01 01:15:39 +01:00
Suppress BrokenPipeError in logging
https://bugzilla.redhat.com/show_bug.cgi?id=1903583 sports the following traceback: Traceback (most recent call last): File "/usr/bin/ebook-convert", line 20, in <module> sys.exit(main()) File "/usr/lib64/calibre/calibre/ebooks/conversion/cli.py", line 401, in main plumber.run() File "/usr/lib64/calibre/calibre/ebooks/conversion/plumber.py", line 1135, in run pr(0., _('Running transforms on e-book...')) File "/usr/lib64/calibre/calibre/ebooks/conversion/plumber.py", line 67, in __call__ self.global_reporter(global_frac, msg) File "/usr/lib64/calibre/calibre/ebooks/conversion/cli.py", line 288, in __call__ self.log('%d%% %s'%(percent, msg)) File "/usr/lib64/calibre/calibre/utils/logging.py", line 179, in __call__ self.info(*args, **kwargs) File "/usr/lib64/calibre/calibre/utils/logging.py", line 171, in print_with_flush self.flush() File "/usr/lib64/calibre/calibre/utils/logging.py", line 191, in flush o.flush() File "/usr/lib64/calibre/calibre/utils/logging.py", line 53, in flush self.stream.flush() BrokenPipeError: [Errno 32] Datenübergabe unterbrochen (broken pipe) If logging fails because somebody closed the output pipe, this is not an error. Let's just ignore this this silently. I removed the two .flush() implementations because those two classes inherit from Stream.
This commit is contained in:
parent
52c55cc42e
commit
fa8bbfda15
1 changed files with 5 additions and 7 deletions
|
|
@ -31,7 +31,11 @@ def write(self, text):
|
|||
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 @@ def prints(self, level, *args, **kwargs):
|
|||
with ColoredStream(self.stream, self.color[level]):
|
||||
self._prints(*args, **kwargs)
|
||||
|
||||
def flush(self):
|
||||
self.stream.flush()
|
||||
|
||||
|
||||
class FileStream(Stream):
|
||||
|
||||
|
|
@ -94,9 +95,6 @@ def prints(self, level, *args, **kwargs):
|
|||
self._prints(*args, **kwargs)
|
||||
self._prints(self.normal, end='')
|
||||
|
||||
def flush(self):
|
||||
self.stream.flush()
|
||||
|
||||
|
||||
class UnicodeHTMLStream(HTMLStream):
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue