1. 11

  2. 3

    This issue is more generic than Python… the true problem comes from piping STDIN and STDOUT from a subprocess.

    One other alternative is to make sure that you are always streaming the STDOUT and STDERR of a subprocess to a dedicated file rather than to subprocess.PIPE.

    1. 1

      Yes you are absolutely correct, the place where I ran into this was with python but it can certainly happen wherever you are piping STDIN and STDOUT and not properly handling the data. In python even thought the documentation does warn about this it still seems like an easy bug to introduce and can be weird to debug.

      1. 1

        The issue isn’t too hard to solve by poll()ing the FDs. The deadlock is an implementation issue.

      2. 1

        Another easy solution is redirecting stderr to stdout:

        proc = subprocess.Popen(…, stderr=subprocess.STDOUT)

        1. 1

          if merging those two streams is an acceptable thing to do. (It’s usually not, I’d say.)