You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/12/06 17:14:59 UTC

git commit: [#6821] Handle errors in threaded git LCDs without indefinitely blocking request

Updated Branches:
  refs/heads/cj/6821 [created] 2efd324d5


[#6821] Handle errors in threaded git LCDs without indefinitely blocking request

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/2efd324d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/2efd324d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/2efd324d

Branch: refs/heads/cj/6821
Commit: 2efd324d55fdcc78f98fa4a2d035cb3215fcad0a
Parents: 6426ead
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Fri Dec 6 16:02:59 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Fri Dec 6 16:02:59 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/2efd324d/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/2efd324d/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/2efd324d/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