Fixes: #14354
Signed-off-by: Bo Cai <cai.bo@h3c.com>
if suffix != '':
outbuf = outbuf.rstrip()
if outbuf != '':
- # Write directly to binary stdout
- raw_stdout.write(prefix)
- raw_stdout.write(outbuf)
- raw_stdout.write(suffix)
+ try:
+ # Write directly to binary stdout
+ raw_stdout.write(prefix)
+ raw_stdout.write(outbuf)
+ raw_stdout.write(suffix)
+ except IOError as e:
+ if e.errno != errno.EPIPE:
+ raise e
sys.stdout.flush()