Skip to content

Commit

Permalink
Remove 'broken pipe' workaround for Click (sonic-net#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
jleveque authored and lguohan committed Aug 1, 2018
1 parent f02073e commit 08358a1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
14 changes: 2 additions & 12 deletions connect/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,8 @@ def run_command(command, display_cmd=False):
output = proc.stdout.readline()
if output == "" and proc.poll() is not None:
break
if output:
try:
click.echo(output.rstrip('\n'))
except IOError as e:
# In our version of Click (v6.6), click.echo() and click.echo_via_pager() do not properly handle
# SIGPIPE, and if a pipe is broken before all output is processed (e.g., pipe output to 'head'),
# it will result in a stack trace. This is apparently fixed upstream, but for now, we silently
# ignore SIGPIPE here.
if e.errno == errno.EPIPE:
sys.exit(0)
else:
raise
elif output:
click.echo(output.rstrip('\n'))

rc = proc.poll()
if rc != 0:
Expand Down
12 changes: 1 addition & 11 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,7 @@ def run_command(command, display_cmd=False):
if output == "" and proc.poll() is not None:
break
if output:
try:
click.echo(output.rstrip('\n'))
except IOError as e:
# In our version of Click (v6.6), click.echo() and click.echo_via_pager() do not properly handle
# SIGPIPE, and if a pipe is broken before all output is processed (e.g., pipe output to 'head'),
# it will result in a stack trace. This is apparently fixed upstream, but for now, we silently
# ignore SIGPIPE here.
if e.errno == errno.EPIPE:
sys.exit(0)
else:
raise
click.echo(output.rstrip('\n'))

rc = proc.poll()
if rc != 0:
Expand Down

0 comments on commit 08358a1

Please sign in to comment.