From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 75EFD13888F for ; Tue, 6 Oct 2015 16:27:52 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 08CD0E0818; Tue, 6 Oct 2015 16:27:52 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 9AEFEE0818 for ; Tue, 6 Oct 2015 16:27:51 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A12F5340806 for ; Tue, 6 Oct 2015 16:27:50 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id B7D56AD8 for ; Tue, 6 Oct 2015 16:27:47 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1444148737.4205ec912aebf2e3b0bd673fcacb576b1f344329.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/sync/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/sync/controller.py X-VCS-Directories: pym/portage/sync/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 4205ec912aebf2e3b0bd673fcacb576b1f344329 X-VCS-Branch: master Date: Tue, 6 Oct 2015 16:27:47 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 5a418fd7-5d79-4beb-8e48-d09cfe4d6d71 X-Archives-Hash: 6783d637ef2aae9a46eb27eb4a2a748f commit: 4205ec912aebf2e3b0bd673fcacb576b1f344329 Author: Zac Medico gentoo org> AuthorDate: Mon Oct 5 23:01:49 2015 +0000 Commit: Zac Medico gentoo org> CommitDate: Tue Oct 6 16:25:37 2015 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=4205ec91 SyncRepos.async: group sync and callback as composite task (bug 562264) Group together the sync operation and the callback as a single task, so that the callback will not execute concurrently with another sync operation for --jobs=1. X-Gentoo-Bug: 562264 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=562264 Acked-by: Brian Dolbec gentoo.org> pym/portage/sync/controller.py | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/pym/portage/sync/controller.py b/pym/portage/sync/controller.py index 28dbc57..159b9c0 100644 --- a/pym/portage/sync/controller.py +++ b/pym/portage/sync/controller.py @@ -25,6 +25,7 @@ from portage.util._async.AsyncFunction import AsyncFunction from portage import OrderedDict from portage import _unicode_decode from portage import util +from _emerge.CompositeTask import CompositeTask class TaskHandler(object): @@ -119,10 +120,9 @@ class SyncManager(object): self.settings, self.trees, self.mtimedb = emerge_config self.xterm_titles = "notitles" not in self.settings.features self.portdb = self.trees[self.settings['EROOT']]['porttree'].dbapi - proc = AsyncFunction(target=self.sync, - kwargs=dict(emerge_config=emerge_config, repo=repo)) - proc.addExitListener(self._sync_callback) - return proc + return SyncRepo(sync_task=AsyncFunction(target=self.sync, + kwargs=dict(emerge_config=emerge_config, repo=repo)), + sync_callback=self._sync_callback) def sync(self, emerge_config=None, repo=None): self.callback = None @@ -343,3 +343,34 @@ class SyncManager(object): action_metadata(self.settings, self.portdb, self.emerge_config.opts, porttrees=[repo.location]) + +class SyncRepo(CompositeTask): + """ + Encapsulates a sync operation and the callback which executes afterwards, + so both can be considered as a single composite task. This is useful + since we don't want to consider a particular repo's sync operation as + complete until after the callback has executed (bug 562264). + + The kwargs and result properties expose attributes that are accessed + by SyncScheduler. + """ + + __slots__ = ('sync_task', 'sync_callback') + + @property + def kwargs(self): + return self.sync_task.kwargs + + @property + def result(self): + return self.sync_task.result + + def _start(self): + self._start_task(self.sync_task, self._sync_task_exit) + + def _sync_task_exit(self, sync_task): + self._current_task = None + self.returncode = sync_task.returncode + self.sync_callback(self.sync_task) + self._async_wait() +