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)