Skip to content
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

cleo does not handle SIGPIPE / errno.EPIPE #56

Closed
kadrach opened this issue Aug 3, 2018 · 2 comments · Fixed by #236
Closed

cleo does not handle SIGPIPE / errno.EPIPE #56

kadrach opened this issue Aug 3, 2018 · 2 comments · Fixed by #236

Comments

@kadrach
Copy link

kadrach commented Aug 3, 2018

Discovered this trying to work around python-poetry/poetry#106 doing something along the lines of poetry show -v | head -n1 | ...

Using the GreetCommand given in the README:

% python app.py | head
Console Tool

Usage:
  command [options] [arguments]

Options:
  -h, --help                      Display this help message
  -q, --quiet                     Do not output any message
  -V, --version                   Display this application version
      --ansi                      Force ANSI output


  [BrokenPipeError]
  [Errno 32] Broken pipe


list [--raw] [--format FORMAT] [--] [<namespace>]

Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe
% echo $?
0
@zmitchell
Copy link

zmitchell commented Feb 9, 2019

Edit: I didn't see that poetry uses cleo 0.6.8, and the current version is 0.7.2, so I'm not sure yet if the problem still exists in the current version.

This is the cause of python-poetry/poetry#839. In that issue I reference a StackOverflow post with a solution. Here is the short version:

# in cleo/outputs/stream_output.py
from signal import signal, SIGPIPE, SIG_DFL
signal(SIGPIPE, SIG_DFL)

The process writing to the pipe will now be terminated when it receives SIGPIPE (i.e. when the other end of the pipe is closed prematurely), rather than raising a BrokenPipeError.

I would be more than willing to put together a PR for this since it's very little code.

@iamkroot
Copy link

iamkroot commented Dec 19, 2019

Facing the same issue while doing the same thing. @zmitchell did you ever figure out a solution that doesn't require editing the source?

EDIT: Found the env command for poetry, which gives the virtualenv path - poetry env info -p. This solves my problem for now, but it would still be nice to see this issue resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants