-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Broken pipe on piping list
output on Python 3
#2622
Comments
list
outputlist
output on Python 3
Thank you! I can reproduce this, and it looks like it's a new problem on Python 3. We actually have a specific exception handler for closed pipes on Python 2, but the same technique apparently doesn't work on Python 3. I don't fully understand what's going on with the "Exception ignored" mechanism… some further digging is required here. |
Reading https://stackoverflow.com/a/26738736, and testing it, it seems replacing I don't know if it could hide useful information in the future though. I think it won't since this is for a very specific errno. @Azphreal could you check that the branch Fix-2622 works on your end as well? |
For some reason Python always warns about a BrokenPipeError on stderr even if it is caught. Fixes #2622
Huh! Wow! Thanks for looking into it—this isn't precisely what I expected, but it makes sense. I suppose the problem is that just ignoring the exception caused some sort of internal exception handler to trigger, which can't produce anything because the output streams are already shutting down. Closing the pipe avoids that. This does indeed looks like the right fix; let's do it! ✨ I believe an extra flush should probably be unnecessary—each write we do to stderr should be followed by a flush already. For example, the main thing we do is call |
Do not warn about a BrokenPipeError we do consider - Fix #2622
Problem
I'm trying to write a quick dirty script to play the first result of a search, looking much like you'd expect:
mpv --no-audio-display "$(beet ls -p $@ | head -n 1)"
However, there's something in the formatting of the output that
head
doesn't like:However
Trying to cheat and run it through
echo
instead produces the following:as one string, so it seems like the proper line-ending characters aren't being properly generated. This may be expected of Python output, I don't know; I haven't written using it.
End question I suppose is there any way around how Python handles printing lines short of rewriting that entire part of the program?
Setup
My configuration (output of
beet config
) shouldn't matter, because it's a question of how the program functions inherently.The text was updated successfully, but these errors were encountered: