This commit is contained in:
JWilson001 2026-05-10 20:36:41 +08:00 committed by GitHub
commit 158b8a3b12
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -332,8 +332,14 @@ try:
if '100%' in message: if '100%' in message:
self.sync_write(message) self.sync_write(message)
else: else:
write_stderr(message) # Wrap flush() to match the safer behaviour of
original_stderr.flush() # self.flush() below — a broken pipe must not
# kill the calling print() (and thus the node).
try:
write_stderr(message)
original_stderr.flush()
except (OSError, ValueError):
pass
else: else:
self.sync_write(message) self.sync_write(message)
else: else:
@ -356,12 +362,20 @@ try:
if not file_only: if not file_only:
with std_log_lock: with std_log_lock:
if self.is_stdout: # Wrap flush() in try/except to match self.flush()
write_stdout(message) # below. Without this, an OSError from a broken
original_stdout.flush() # stdio pipe (e.g. Windows [Errno 22] Invalid argument)
else: # propagates up through every print() call in every
write_stderr(message) # custom node, killing prompt execution.
original_stderr.flush() try:
if self.is_stdout:
write_stdout(message)
original_stdout.flush()
else:
write_stderr(message)
original_stderr.flush()
except (OSError, ValueError):
pass
def flush(self): def flush(self):
try: try: