From 2cc8f1e3c6627f0b4da7cb6550f7252f76529d8e Mon Sep 17 00:00:00 2001 From: Ivan Ryabchenko Date: Thu, 15 Oct 2015 12:23:21 +0600 Subject: [PATCH] fix(cmd): fixed deadlock when stderr buffer overflow Fixed deadlock when using stderr=PIPE in Popen and Git generates enough output to a pipe such that it blocks waiting for the OS pipe buffer to accept more data (see https://docs.python.org/2/library/subprocess.html#subprocess.Popen.wait) --- git/cmd.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/git/cmd.py b/git/cmd.py index 3cdc68ab7..6cf4d8a65 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -310,11 +310,11 @@ def wait(self): """Wait for the process and return its status code. :raise GitCommandError: if the return status is not 0""" - status = self.proc.wait() - if status != 0: - raise GitCommandError(self.args, status, self.proc.stderr.read()) + stderr_value = self.proc.communicate()[1] + if self.proc.returncode != 0: + raise GitCommandError(self.args, status, stderr_value) # END status handling - return status + return self.proc.returncode # END auto interrupt class CatFileContentStream(object):