Skip to content

Commit 08358a1

Browse files
jlevequelguohan
authored andcommitted
Remove 'broken pipe' workaround for Click (sonic-net#286)
1 parent f02073e commit 08358a1

File tree

2 files changed

+3
-23
lines changed

2 files changed

+3
-23
lines changed

connect/main.py

+2-12
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,8 @@ def run_command(command, display_cmd=False):
9191
output = proc.stdout.readline()
9292
if output == "" and proc.poll() is not None:
9393
break
94-
if output:
95-
try:
96-
click.echo(output.rstrip('\n'))
97-
except IOError as e:
98-
# In our version of Click (v6.6), click.echo() and click.echo_via_pager() do not properly handle
99-
# SIGPIPE, and if a pipe is broken before all output is processed (e.g., pipe output to 'head'),
100-
# it will result in a stack trace. This is apparently fixed upstream, but for now, we silently
101-
# ignore SIGPIPE here.
102-
if e.errno == errno.EPIPE:
103-
sys.exit(0)
104-
else:
105-
raise
94+
elif output:
95+
click.echo(output.rstrip('\n'))
10696

10797
rc = proc.poll()
10898
if rc != 0:

show/main.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,7 @@ def run_command(command, display_cmd=False):
123123
if output == "" and proc.poll() is not None:
124124
break
125125
if output:
126-
try:
127-
click.echo(output.rstrip('\n'))
128-
except IOError as e:
129-
# In our version of Click (v6.6), click.echo() and click.echo_via_pager() do not properly handle
130-
# SIGPIPE, and if a pipe is broken before all output is processed (e.g., pipe output to 'head'),
131-
# it will result in a stack trace. This is apparently fixed upstream, but for now, we silently
132-
# ignore SIGPIPE here.
133-
if e.errno == errno.EPIPE:
134-
sys.exit(0)
135-
else:
136-
raise
126+
click.echo(output.rstrip('\n'))
137127

138128
rc = proc.poll()
139129
if rc != 0:

0 commit comments

Comments
 (0)