summaryrefslogtreecommitdiff
path: root/git/cmd.py
diff options
context:
space:
mode:
Diffstat (limited to 'git/cmd.py')
-rw-r--r--git/cmd.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/git/cmd.py b/git/cmd.py
index fd3e815b..392f3a0b 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -602,8 +602,6 @@ class Git(LazyMixin):
if as_process:
return self.AutoInterrupt(proc, command)
- kill_check = threading.Event()
-
def _kill_process(pid):
""" Callback method to kill a process. """
p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE)
@@ -625,7 +623,9 @@ class Git(LazyMixin):
return
# end
- watchdog = threading.Timer(timeout, _kill_process, args=(proc.pid, ))
+ if timeout:
+ kill_check = threading.Event()
+ watchdog = threading.Timer(timeout, _kill_process, args=(proc.pid, ))
# Wait for the process to return
status = 0
@@ -633,12 +633,14 @@ class Git(LazyMixin):
stderr_value = b''
try:
if output_stream is None:
- watchdog.start()
+ if timeout:
+ watchdog.start()
stdout_value, stderr_value = proc.communicate()
- watchdog.cancel()
- if kill_check.isSet():
- stderr_value = 'Timeout: the command "%s" did not complete in %d ' \
- 'secs.' % (" ".join(command), timeout)
+ if timeout:
+ watchdog.cancel()
+ if kill_check.isSet():
+ stderr_value = 'Timeout: the command "%s" did not complete in %d ' \
+ 'secs.' % (" ".join(command), timeout)
# strip trailing "\n"
if stdout_value.endswith(b"\n"):
stdout_value = stdout_value[:-1]