From 67dccd29ceb6c25d91cfed0830abcfe2787b2738 Mon Sep 17 00:00:00 2001 From: Oliver van Porten Date: Wed, 2 Sep 2020 21:05:20 +0200 Subject: [PATCH 1/4] Fix potential deadlock when using git-lfs Use p.communicate() instead of of .read() on stderr/stdout directly as that seems to cause a deadlock with large outputs (or at least that is what I think happens). Before this change zest.releaser would get stuck doing a clone of the repository, if the repository uses git-lfs. --- zest/releaser/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zest/releaser/utils.py b/zest/releaser/utils.py index 6868ec3c..f0ee828e 100644 --- a/zest/releaser/utils.py +++ b/zest/releaser/utils.py @@ -745,8 +745,7 @@ def _subprocess_open(p, command, input_value, show_stderr): if input_value: i.write(input_value.encode(INPUT_ENCODING)) i.close() - stdout_output = o.read() - stderr_output = e.read() + (stdout_output, stderr_output) = p.communicate() # We assume that the output from commands we're running is text. if not isinstance(stdout_output, six.text_type): stdout_output = stdout_output.decode(OUTPUT_ENCODING) From b67cac620d63a14fbe45d8d7276504064e643160 Mon Sep 17 00:00:00 2001 From: Oliver van Porten Date: Wed, 2 Sep 2020 21:09:21 +0200 Subject: [PATCH 2/4] Fix TypeError in subprocess under Python 2.7 This fixes ``TypeError: environment can only contain strings`` emitted by subprocess. Subprocess seems to dislike unicode objects in os.environ/env that is passed. This assures a plain string is used instead. --- zest/releaser/baserelease.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zest/releaser/baserelease.py b/zest/releaser/baserelease.py index 0dc13cca..4fc9ff87 100644 --- a/zest/releaser/baserelease.py +++ b/zest/releaser/baserelease.py @@ -57,7 +57,7 @@ class Basereleaser(object): def __init__(self, vcs=None): - os.environ["ZESTRELEASER"] = "We are called from within zest.releaser" + os.environ[str("ZESTRELEASER")] = str("We are called from within zest.releaser") # ^^^ Env variable so called tools can detect us. Don't depend on the # actual text, just on the variable's name. if vcs is None: From 4ec2a33f46b11d0abdbc3779109d2c3276328e3f Mon Sep 17 00:00:00 2001 From: Oliver van Porten Date: Thu, 3 Sep 2020 09:55:21 +0200 Subject: [PATCH 3/4] Fix failing CI build --- zest/releaser/utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/zest/releaser/utils.py b/zest/releaser/utils.py index f0ee828e..168225d1 100644 --- a/zest/releaser/utils.py +++ b/zest/releaser/utils.py @@ -741,11 +741,10 @@ def format_command(command): def _subprocess_open(p, command, input_value, show_stderr): - i, o, e = (p.stdin, p.stdout, p.stderr) if input_value: - i.write(input_value.encode(INPUT_ENCODING)) - i.close() - (stdout_output, stderr_output) = p.communicate() + (stdout_output, stderr_output) = p.communicate(input_value.encode(INPUT_ENCODING)) + else: + (stdout_output, stderr_output) = p.communicate() # We assume that the output from commands we're running is text. if not isinstance(stdout_output, six.text_type): stdout_output = stdout_output.decode(OUTPUT_ENCODING) From 58342ce98c7b7e7574e16e9a153141319b2caec8 Mon Sep 17 00:00:00 2001 From: Oliver van Porten Date: Thu, 3 Sep 2020 20:28:43 +0200 Subject: [PATCH 4/4] Fix use of variables that no longer exist --- zest/releaser/utils.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/zest/releaser/utils.py b/zest/releaser/utils.py index 168225d1..5973b366 100644 --- a/zest/releaser/utils.py +++ b/zest/releaser/utils.py @@ -764,8 +764,6 @@ def _subprocess_open(p, command, input_value, show_stderr): if stderr_output: logger.debug("Stderr of running command '%s':\n%s", format_command(command), stderr_output) - o.close() - e.close() return result