From e3165753f9d0d69caabac74eee195887f3fea482 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Wed, 12 Oct 2016 22:58:41 +0200 Subject: [PATCH] pumps: FIX don't pump when proc has no streams --- git/cmd.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/git/cmd.py b/git/cmd.py index 88d62aa45..a92b2f3ce 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -92,11 +92,16 @@ def pump_stream(cmdline, name, stream, is_decode, handler): cmdline = getattr(process, 'args', '') # PY3+ only if not isinstance(cmdline, (tuple, list)): cmdline = cmdline.split() + + pumps = [] + if process.stdout: + pumps.append(('stdout', process.stdout, stdout_handler)) + if process.stderr: + pumps.append(('stderr', process.stderr, stderr_handler)) + threads = [] - for name, stream, handler in ( - ('stdout', process.stdout, stdout_handler), - ('stderr', process.stderr, stderr_handler), - ): + + for name, stream, handler in pumps: t = threading.Thread(target=pump_stream, args=(cmdline, name, stream, decode_streams, handler)) t.setDaemon(True)