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 558F910FB6 for ; Fri, 20 Dec 2013 18:50:29 +0000 (UTC) Received: (qmail 59692 invoked by uid 500); 20 Dec 2013 18:50:29 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 59617 invoked by uid 500); 20 Dec 2013 18:50:29 -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 58818 invoked by uid 99); 20 Dec 2013 18:50:28 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Dec 2013 18:50:28 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 493AC324072; Fri, 20 Dec 2013 18:50:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: brondsem@apache.org To: allura-commits@incubator.apache.org Date: Fri, 20 Dec 2013 18:50:46 -0000 Message-Id: <91514c4e770a4058b031b9e0c500aaad@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [20/36] git commit: [#6821] Remove any possibility of indefinite blocking and make test more clear [#6821] Remove any possibility of indefinite blocking and make test more clear 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/e8d402ba Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/e8d402ba Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/e8d402ba Branch: refs/heads/db/6388 Commit: e8d402ba8283e40614ae495078156c0f1c0c3181 Parents: 4070bed Author: Cory Johns Authored: Mon Dec 16 19:20:34 2013 +0000 Committer: Dave Brondsema Committed: Wed Dec 18 22:10:34 2013 +0000 ---------------------------------------------------------------------- Allura/allura/model/repository.py | 11 ++++++++++- ForgeGit/forgegit/tests/model/test_repository.py | 7 ++++--- 2 files changed, 14 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e8d402ba/Allura/allura/model/repository.py ---------------------------------------------------------------------- diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py index 169b365..2aeef64 100644 --- a/Allura/allura/model/repository.py +++ b/Allura/allura/model/repository.py @@ -288,7 +288,16 @@ class RepositoryImplementation(object): for i in range(num_threads): t = Thread(target=get_ids) t.start() - chunks.join() + # reimplement chunks.join() but with a timeout + # see: http://bugs.python.org/issue9634 + # (giving threads a bit of extra cleanup time in case they timeout) + chunks.all_tasks_done.acquire() + try: + endtime = time() + timeout + 0.5 + while chunks.unfinished_tasks and endtime > time(): + chunks.all_tasks_done.wait(endtime - time()) + finally: + chunks.all_tasks_done.release() return result class Repository(Artifact, ActivityObject): http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e8d402ba/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 8569025..4f4f56f 100644 --- a/ForgeGit/forgegit/tests/model/test_repository.py +++ b/ForgeGit/forgegit/tests/model/test_repository.py @@ -456,13 +456,14 @@ 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): + @mock.patch('forgegit.model.git_repo.GitImplementation._git', new_callable=mock.PropertyMock) + def test_last_commit_ids_threaded_error(self, _git): + with h.push_config(tg.config, lcd_thread_chunk_size=1, lcd_timeout=2): repo_dir = pkg_resources.resource_filename( 'forgegit', 'tests/data/testrename.git') repo = mock.Mock(full_fs_path=repo_dir) + _git.side_effect = ValueError 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, {})