Return-Path: X-Original-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9510610082 for ; Mon, 16 Dec 2013 17:11:04 +0000 (UTC) Received: (qmail 59529 invoked by uid 500); 16 Dec 2013 17:09:56 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 59292 invoked by uid 500); 16 Dec 2013 17:09:49 -0000 Mailing-List: contact allura-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: allura-dev@incubator.apache.org Delivered-To: mailing list allura-commits@incubator.apache.org Received: (qmail 58945 invoked by uid 99); 16 Dec 2013 17:09:41 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Dec 2013 17:09:41 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 101DB9183B2; Mon, 16 Dec 2013 17:09:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: johnsca@apache.org To: allura-commits@incubator.apache.org Date: Mon, 16 Dec 2013 17:10:15 -0000 Message-Id: <37da8971b72b43d793bb95c435bbe04e@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [36/36] git commit: [#6821] Handle errors in threaded git LCDs without indefinitely blocking request [#6821] Handle errors in threaded git LCDs without indefinitely blocking request Signed-off-by: Cory Johns Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/ad87c159 Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/ad87c159 Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/ad87c159 Branch: refs/heads/cj/6821 Commit: ad87c1599a697c386278d54bdb48814675174e80 Parents: a113345 Author: Cory Johns Authored: Fri Dec 6 16:02:59 2013 +0000 Committer: Cory Johns Committed: Mon Dec 16 17:09:15 2013 +0000 ---------------------------------------------------------------------- ForgeGit/forgegit/model/git_repo.py | 41 +++++++++++--------- .../forgegit/tests/model/test_repository.py | 10 +++++ requirements-sf.txt | 2 +- 3 files changed, 33 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ad87c159/ForgeGit/forgegit/model/git_repo.py ---------------------------------------------------------------------- diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py index 145e528..f08fdd4 100644 --- a/ForgeGit/forgegit/model/git_repo.py +++ b/ForgeGit/forgegit/model/git_repo.py @@ -518,25 +518,28 @@ class GitImplementation(M.RepositoryImplementation): num_threads += 1 def get_ids(): paths = set(chunks.get()) - commit_id = commit._id - while paths and commit_id: - if time() - start_time > timeout: - log.error('last_commit_ids timeout for %s on %s', commit._id, ', '.join(paths)) - break - lines = self._git.git.log( - commit._id, '--', *paths, - pretty='format:%H', - name_only=True, - max_count=1, - no_merges=True).split('\n') - commit_id = lines[0] - changes = set(lines[1:]) - changed = prefix_paths_union(paths, changes) - for path in changed: - result[path] = commit_id - paths -= changed - chunks.task_done() - return + try: + commit_id = commit._id + while paths and commit_id: + if time() - start_time > timeout: + log.error('last_commit_ids timeout for %s on %s', commit._id, ', '.join(paths)) + break + lines = self._git.git.log( + commit._id, '--', *paths, + pretty='format:%H', + name_only=True, + max_count=1, + no_merges=True).split('\n') + commit_id = lines[0] + changes = set(lines[1:]) + changed = prefix_paths_union(paths, changes) + for path in changed: + result[path] = commit_id + paths -= changed + except Exception as e: + log.exception('Error in Git thread: %s', e) + finally: + chunks.task_done() if num_threads == 1: get_ids() else: http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ad87c159/ForgeGit/forgegit/tests/model/test_repository.py ---------------------------------------------------------------------- diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py index d2a9413..8569025 100644 --- a/ForgeGit/forgegit/tests/model/test_repository.py +++ b/ForgeGit/forgegit/tests/model/test_repository.py @@ -456,6 +456,16 @@ class TestGitImplementation(unittest.TestCase): with h.push_config(tg.config, lcd_thread_chunk_size=1): self.test_last_commit_ids() + def test_last_commit_ids_threaded_error(self): + with h.push_config(tg.config, lcd_thread_chunk_size=1): + repo_dir = pkg_resources.resource_filename( + 'forgegit', 'tests/data/testrename.git') + repo = mock.Mock(full_fs_path=repo_dir) + impl = GM.git_repo.GitImplementation(repo) + impl._git = None + lcds = impl.last_commit_ids(mock.Mock(_id='13951944969cf45a701bf90f83647b309815e6d5'), ['f2.txt', 'f3.txt']) + self.assertEqual(lcds, {}) + class TestGitCommit(unittest.TestCase): http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ad87c159/requirements-sf.txt ---------------------------------------------------------------------- diff --git a/requirements-sf.txt b/requirements-sf.txt index b46c8ea..f9773e9 100644 --- a/requirements-sf.txt +++ b/requirements-sf.txt @@ -4,7 +4,7 @@ akismet==0.2.0 amqplib==0.6.1 kombu==1.0.4 coverage==3.5a1-20110413 -ForgeHg==0.1.18 +ForgeHg==0.1.19 ForgePastebin==0.2.7 GoogleCodeWikiImporter==0.4.7 mechanize==0.2.4