-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exit on EPIPE #1393
Exit on EPIPE #1393
Conversation
if e.errno == errno.EPIPE: | ||
exit() | ||
else: | ||
raise e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The callback function can be arbitrary user function here. Why you single out EPIPE errno from
another other exceptions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the developer makes a mistake in his callback function (say, write to a file on which she doesn't have permissions), we want to display the usual traceback, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any exception should already have a traceback here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. If I exit on every exception (or ignore some), these tracebacks won't be displayed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So why the exit for errno.EPIPE? If you have an example of callback function and/or lost_cb function, probably it is easier to try and understand your point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal is to properly exit when receiving EPIPE or SIGPIPE as described in #1010.
If you take the example from #1010, when running ./opensnoop.py | head
, it will display 10 lines then exception tracebacks for each new line without exiting because of the EPIPE Exception. With the present pull request it will properly exit (call cleanup and not display a traceback) on the first EPIPE Exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed the original pointer to the issue number. The change looks good to me. Thanks for the fix!
Fixes #1010.
/cc @brendangregg