From 6874ea096677a256d7eb25815403c424d691f140 Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Mon, 14 Apr 2014 10:54:35 +0800 Subject: [PATCH] Git processes can be killed using CTRL + C --- lib/git.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/git.py b/lib/git.py index da7ee3b..d3733e3 100644 --- a/lib/git.py +++ b/lib/git.py @@ -129,12 +129,17 @@ class Git(object): logging.debug(' '.join(cmd)) - proc = subprocess.Popen(cmd, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - cwd=path - ) - (stdout, stderr) = proc.communicate() + try: + proc = subprocess.Popen(cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=path + ) + (stdout, stderr) = proc.communicate() + except KeyboardInterrupt as e: + proc.kill() + raise e + return (proc.returncode, stdout, stderr) def fetch(self, remote='', ref=''): -- 2.11.0