From 8b51f1bfa4cec0cba485dee96b1d9d0b1154eb67 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 10 Nov 2019 09:32:05 -0500 Subject: [PATCH] Catch subprocess timeout on tarball prep --- gitsrht/blueprints/repo.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gitsrht/blueprints/repo.py b/gitsrht/blueprints/repo.py index 3f0c532..55d95a0 100644 --- a/gitsrht/blueprints/repo.py +++ b/gitsrht/blueprints/repo.py @@ -351,13 +351,16 @@ def patch(owner, repo, ref): abort(404) if isinstance(commit, pygit2.Tag): ref = git_repo.get(commit.target) - subp = subprocess.run([ - "git", - "--git-dir", repo.path, - "format-patch", - "--stdout", "-1", - ref - ], timeout=10, stdout=subprocess.PIPE, stderr=sys.stderr) + try: + subp = subprocess.run([ + "git", + "--git-dir", repo.path, + "format-patch", + "--stdout", "-1", + ref + ], timeout=10, stdout=subprocess.PIPE, stderr=sys.stderr) + except subprocess.TimeoutExpired: + return "Operation timed out", 500 if subp.returncode != 0: return "Error preparing patch", 500 return Response(subp.stdout, mimetype='text/plain') -- 2.38.4