Skip to content

Commit 9f94665

Browse files
committed
Suppress BrokenPipeError when saving downloaded content to stdout
1 parent 9ee87a0 commit 9f94665

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

b2sdk/_internal/transfer/inbound/downloaded_file.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,12 @@ def save_to(
274274
try:
275275
with context as file:
276276
return self.save(file, allow_seeking=allow_seeking)
277+
except BrokenPipeError as ex:
278+
if is_stdout:
279+
# Output was likely piped through a command such as head. Just ignore the error
280+
return
281+
else:
282+
raise ex
277283
finally:
278284
if not is_stdout:
279285
set_file_mtime(path_, self.download_version.mod_time_millis)

changelog.d/534.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Suppress BrokenPipeError when saving downloaded content to stdout.

0 commit comments

Comments
 (0)