Skip to content

Commit 4b72b77

Browse files
committed
pythongh-134568: added handler for BrokenPipeError to logging.StreamHandler.emit
1 parent 366d95d commit 4b72b77

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Lib/logging/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,10 @@ def emit(self, record):
11551155
self.flush()
11561156
except RecursionError: # See issue 36272
11571157
raise
1158+
except BrokenPipeError:
1159+
devnull = os.open(os.devnull, os.O_WRONLY)
1160+
os.dup2(devnull, sys.stdout.fileno())
1161+
sys.exit(1)
11581162
except Exception:
11591163
self.handleError(record)
11601164

0 commit comments

Comments
 (0)