-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-134568: added handler for BrokenPipeError to logging.StreamHandler.emit #134569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@@ -1155,6 +1155,10 @@ def emit(self, record): | |||
self.flush() | |||
except RecursionError: # See issue 36272 | |||
raise | |||
except BrokenPipeError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add a "See issue XXXX" as above for the RecursionError maybe. However, shouldn't we give the possibility to handle the error? maybe BrokenPipeError
is coming from somewhere else? Here, you're redirecting sys.stdout
but what if it's because of self.stream
? (I don't know which is why I ask)
except BrokenPipeError: | ||
devnull = os.open(os.devnull, os.O_WRONLY) | ||
os.dup2(devnull, sys.stdout.fileno()) | ||
sys.exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, why are we exiting the process?
@@ -1155,6 +1155,10 @@ def emit(self, record): | |||
self.flush() | |||
except RecursionError: # See issue 36272 | |||
raise | |||
except BrokenPipeError: | |||
devnull = os.open(os.devnull, os.O_WRONLY) | |||
os.dup2(devnull, sys.stdout.fileno()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this have weird side-effects? Any future stdout writes won't show up.
See also my comments on the issue. |
Uh oh!
There was an error while loading. Please reload this page.