From 03e862aa705164f1f2907abbfa49367251931f39 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 17 Apr 2019 09:27:57 +0530 Subject: [PATCH] py3: Fix passing stdout/stderr to RotatingLog not working --- src/calibre/srv/utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/calibre/srv/utils.py b/src/calibre/srv/utils.py index 3f31b72b9f..6575787519 100644 --- a/src/calibre/srv/utils.py +++ b/src/calibre/srv/utils.py @@ -322,7 +322,14 @@ class RotatingStream(object): self.set_output() def set_output(self): - self.stream = share_open(self.filename, 'ab', -1 if iswindows else 1) # line buffered + if ispy3: + if iswindows: + self.stream = share_open(self.filename, 'ab') + else: + # see https://bugs.python.org/issue27805 + self.stream = open(os.open(self.filename, os.O_WRONLY|os.O_APPEND|os.O_CREAT|os.O_CLOEXEC), 'wb') + else: + self.stream = share_open(self.filename, 'ab', -1 if iswindows else 1) # line buffered try: self.current_pos = self.stream.tell() except EnvironmentError: