Project

General

Profile

Bug #7575

Ungraceful handling of SIGPIPE

Added by Dominick Rocco about 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
Target version:
Start date:
12/30/2014
Due date:
% Done:

100%

Estimated time:
0.50 h
Duration:

Description

When piped to "head", samweb prints a nasty python traceback and an IOError. This can be resolved using the built-in signal module. From stack overflow, I recently cargo-culted this solution for one of my own scripts:
from signal import signal, SIGPIPE, SIG_DFL
signal(SIGPIPE,SIG_DFL)

Some solutions also involved catching the exception, although that seems less elegant. Original stack overflow entry here: http://stackoverflow.com/questions/14207708/ioerror-errno-32-broken-pipe-python

History

#1 Updated by Robert Illingworth about 5 years ago

  • Status changed from New to Assigned
  • Assignee set to Robert Illingworth
  • Target version set to v2_0
  • Estimated time set to 0.50 h

#2 Updated by Robert Illingworth about 5 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

I'd forgotten alll about this feature when using python in a pipe filter chain... (It only happens if you have a significant amount of output - if there are only a few lines python outputs them before head closes its stdin, so there's no error message.). It'll be in the next release, which doesn't have a target date yet.

Fixed by 7177215

Before:

$ bin/samweb -e samdev list-projects | head -n1
illingwo_test-project-one-file_20140605174506
Traceback (most recent call last):
  File "bin/samweb", line 12, in ?
    sys.exit(samweb_cli.main())
  File "/cloud/login/illingwo/sam_web_client/python/samweb_cli.py", line 1076, in main
    return command.run(cmdoptions, args)
  File "/cloud/login/illingwo/sam_web_client/python/samweb_cli.py", line 445, in run
    print l
IOError: [Errno 32] Broken pipe

After:

$ bin/samweb -e samdev list-projects | head -n1
illingwo_test-project-one-file_20140605174506


Also available in: Atom PDF