# HG changeset patch # User Mads Kiilerich # Date 1462317505 -7200 # Node ID 106259896c7c62cdc468950f73304a498d3811dd # Parent 86d9bee4738ed6f6ad61fa6e0c72cf910e3041ce subprocess: output on stderr doesn't mean that a process failed Git sometimes does that. Threading non-determinism did that we sometimes didn't see it, and sometimes we failed. diff -r 86d9bee4738e -r 106259896c7c kallithea/lib/vcs/subprocessio.py --- a/kallithea/lib/vcs/subprocessio.py Wed May 04 01:18:25 2016 +0200 +++ b/kallithea/lib/vcs/subprocessio.py Wed May 04 01:18:25 2016 +0200 @@ -364,12 +364,9 @@ # Either way, if error (returned by ended process, or implied based on # presence of stuff in stderr output) we error out. # Else, we are happy. - _returncode = _p.poll() - if _returncode or (_returncode is None and bg_err.length): - try: - _p.terminate() - except Exception: - pass + returncode = _p.poll() + if (returncode is not None # process has terminated + and returncode != 0): # and it failed bg_out.stop() out = ''.join(bg_out) bg_err.stop() @@ -384,7 +381,7 @@ "Subprocess exited due to an error:\n" + err) else: raise EnvironmentError( - "Subprocess exited with non 0 ret code:%s" % _returncode) + "Subprocess exited with non 0 ret code: %s" % returncode) self.process = _p self.output = bg_out self.error = bg_err @@ -394,9 +391,14 @@ return self def next(self): - if self.process and self.process.poll(): - err = ''.join(self.error) - raise EnvironmentError("Subprocess exited due to an error:\n" + err) + if self.process: + returncode = self.process.poll() + if (returncode is not None # process has terminated + and returncode != 0): # and it failed + self.output.stop() + self.error.stop() + err = ''.join(self.error) + raise EnvironmentError("Subprocess exited due to an error:\n" + err) return self.output.next() def throw(self, type, value=None, traceback=None):