py.process.cmdexec() hangs if stderr is full

Create issue
Issue #54 resolved
Victor Stinner created an issue

I'm trying a debug version of PyPy which writes a lot of lines to stderr. After few seconds, PyPy hangs. strace shows that there are two processes: * parent : reading on a pipe (a) * child : writing to a pipe (b)

and... pipe (a) and pipe (b) are different. The child is blocked because the pipe (b) is full, and the parent is blocking because there is no data on pipe (a).

The problem is in py.process.cmdexec():

def popen3_exec_cmd(cmd): stdin, stdout, stderr = os.popen3(cmd) out = err = stdout.close() stderr.close()

stderr is full but the parent is still waiting for the end of stdout (process exit).

I think that stdout and stderr should be read at the same time, maybe using non blocking file descriptors and/or select.

Comments (3)

  1. Holger Krekel repo owner

    i've just committed to (mercurial) trunk a new version that always uses Popen and also works on python3, returns encoded out/err. thanks for the patch and issue.

  2. Log in to comment