From acc286992828770ae3fb6add7e9229185ef3f61b Mon Sep 17 00:00:00 2001 From: Michal Srb Date: Mar 26 2020 12:40:26 +0000 Subject: Do not block when waiting for subprocess to finish If the subprocess generates enough output to fill up the pipe, it will block and wait for somebody to read from the pipe before continuing. Signed-off-by: Michal Srb --- diff --git a/pagure/lib/git.py b/pagure/lib/git.py index 4cae87d..405788e 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -1266,8 +1266,8 @@ def read_output(cmd, abspath, input=None, keepends=False, error=False, **kw): cwd=abspath, **kw ) - retcode = procs.wait() (out, err) = procs.communicate(input) + retcode = procs.wait() if isinstance(out, six.binary_type): out = out.decode("utf-8") if isinstance(err, six.binary_type): diff --git a/tests/test_pagure_lib_git.py b/tests/test_pagure_lib_git.py index e15dcac..64ed692 100644 --- a/tests/test_pagure_lib_git.py +++ b/tests/test_pagure_lib_git.py @@ -3169,6 +3169,16 @@ index 0000000..60f7480 ) ) + def test_read_output(self): + here = os.path.dirname(os.path.realpath(__file__)) + # This should't block + self.assertTrue( + pagure.lib.git.read_output( + ["git", "rev-list", "--all"], + here + ) + ) + @patch("pagure.utils.get_repo_path") def test_update_pull_ref(self, get_repo_path): fake_pr = MagicMock()