Skip to content
This repository was archived by the owner on Jun 3, 2021. It is now read-only.

Commit a99285d

Browse files
ignore broken pipe in stdout commands
1 parent 04d14d8 commit a99285d

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

stream/io/ftp.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def download_cmd():
272272

273273
def get_cmd():
274274
import argparse
275-
from stream.io.std import StdOut
275+
from stream.io.std import StdOut, stderr
276276
parser = argparse.ArgumentParser()
277277
parser.add_argument('url', type=str, nargs='?')
278278
parser.add_argument('--host', '-H', type=str)
@@ -290,4 +290,8 @@ def get_cmd():
290290
path,
291291
) as f:
292292
with StdOut() as stdout:
293-
f.dump_to_buffer(stdout.buffer)
293+
try:
294+
f.dump_to_buffer(stdout.buffer)
295+
except BrokenPipeError:
296+
# avoid "exception ignored" message
297+
stderr.close()

stream/io/http.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,15 @@ def download_cmd():
126126

127127
def get_cmd():
128128
import argparse
129-
from stream.io.std import StdOut
129+
from stream.io.std import StdOut, stderr
130130
parser = argparse.ArgumentParser()
131131
parser.add_argument('url', type=str)
132132
args = parser.parse_args()
133133

134134
with HttpDownloadFile(args.url) as f:
135135
with StdOut() as stdout:
136-
f.copy_to(stdout.buffer)
136+
try:
137+
f.copy_to(stdout.buffer)
138+
except BrokenPipeError:
139+
# avoid "exception ignored" message
140+
stderr.close()

stream/io/s3.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def get_cmd():
355355
Stream to stdout
356356
"""
357357
import argparse
358-
from stream.io.std import StdOut
358+
from stream.io.std import StdOut, stderr
359359
parser = argparse.ArgumentParser()
360360
parser.add_argument('bucket')
361361
parser.add_argument('key')
@@ -367,7 +367,11 @@ def get_cmd():
367367
lines=False,
368368
) as f:
369369
with StdOut() as stdout:
370-
f.copy_to(stdout.buffer)
370+
try:
371+
f.copy_to(stdout.buffer)
372+
except BrokenPipeError:
373+
# avoid "exception ignored" message
374+
stderr.close()
371375

372376

373377
def copy_cmd():

0 commit comments

Comments
 (0)