From 6db5a5b91cf9c937094803e572749d9e04782573 Mon Sep 17 00:00:00 2001 From: Michal Srb Date: Mar 28 2020 20:24:53 +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 Merges #4785 --- 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..3e67d42 100644 --- a/tests/test_pagure_lib_git.py +++ b/tests/test_pagure_lib_git.py @@ -3169,6 +3169,13 @@ 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()