From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 4A59E1382C5 for ; Fri, 4 May 2018 17:01:02 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5D536E0870; Fri, 4 May 2018 17:01:01 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 29E93E0870 for ; Fri, 4 May 2018 17:01:00 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B985C335C72 for ; Fri, 4 May 2018 17:00:59 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 87D1732 for ; Fri, 4 May 2018 17:00:57 +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: <1525452692.17604fd598d799c6af24b66fc2c240f90dddd420.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/Binpkg.py pym/_emerge/EbuildBuild.py pym/_emerge/EbuildMerge.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 17604fd598d799c6af24b66fc2c240f90dddd420 X-VCS-Branch: master Date: Fri, 4 May 2018 17:00:57 +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: 7b615e74-7260-428c-953c-40cfd0ba6361 X-Archives-Hash: dff52446be9d38111a7eb6bad40e3f8a commit: 17604fd598d799c6af24b66fc2c240f90dddd420 Author: Zac Medico gentoo org> AuthorDate: Fri May 4 16:47:49 2018 +0000 Commit: Zac Medico gentoo org> CommitDate: Fri May 4 16:51:32 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=17604fd5 EbuildMerge: wait build dir to unlock (bug 654812) Wait for the build dir to unlock, in order to ensure that the category directory is removed when appropriate. Fixes: 720fef408d07 ("Binpkg: use async_unlock (bug 614108)") Fixes: 5ca8ef781952 ("EbuildBuild: use async_unlock (bug 614108)") Bug: https://bugs.gentoo.org/654812 pym/_emerge/Binpkg.py | 12 +++++++++++- pym/_emerge/EbuildBuild.py | 12 +++++++++++- pym/_emerge/EbuildMerge.py | 26 +++++++++++++++++++++----- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/pym/_emerge/Binpkg.py b/pym/_emerge/Binpkg.py index e9c5ef568..2b67816e8 100644 --- a/pym/_emerge/Binpkg.py +++ b/pym/_emerge/Binpkg.py @@ -1,4 +1,4 @@ -# Copyright 1999-2013 Gentoo Foundation +# Copyright 1999-2018 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import functools @@ -428,6 +428,10 @@ class Binpkg(CompositeTask): return task def _install_exit(self, task): + """ + @returns: Future, result is the returncode from an + EbuildBuildDir.async_unlock() task + """ self.settings.pop("PORTAGE_BINPKG_FILE", None) if task.returncode == os.EX_OK and \ 'binpkg-logs' not in self.settings.features and \ @@ -437,3 +441,9 @@ class Binpkg(CompositeTask): except OSError: pass self._async_unlock_builddir() + if self._current_task is None: + result = self.scheduler.create_future() + self.scheduler.call_soon(result.set_result, os.EX_OK) + else: + result = self._current_task.async_wait() + return result diff --git a/pym/_emerge/EbuildBuild.py b/pym/_emerge/EbuildBuild.py index e5b96691a..00d4680f5 100644 --- a/pym/_emerge/EbuildBuild.py +++ b/pym/_emerge/EbuildBuild.py @@ -1,4 +1,4 @@ -# Copyright 1999-2014 Gentoo Foundation +# Copyright 1999-2018 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import unicode_literals @@ -494,4 +494,14 @@ class EbuildBuild(CompositeTask): return task def _install_exit(self, task): + """ + @returns: Future, result is the returncode from an + EbuildBuildDir.async_unlock() task + """ self._async_unlock_builddir() + if self._current_task is None: + result = self.scheduler.create_future() + self.scheduler.call_soon(result.set_result, os.EX_OK) + else: + result = self._current_task.async_wait() + return result diff --git a/pym/_emerge/EbuildMerge.py b/pym/_emerge/EbuildMerge.py index 07d9134c3..bedea902d 100644 --- a/pym/_emerge/EbuildMerge.py +++ b/pym/_emerge/EbuildMerge.py @@ -1,9 +1,12 @@ -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2018 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +import functools + from _emerge.CompositeTask import CompositeTask from portage import os from portage.dbapi._MergeProcess import MergeProcess +from portage.util._async.AsyncTaskFuture import AsyncTaskFuture class EbuildMerge(CompositeTask): @@ -35,8 +38,7 @@ class EbuildMerge(CompositeTask): def _merge_exit(self, merge_task): if self._final_exit(merge_task) != os.EX_OK: - self.exit_hook(self) - self.wait() + self._start_exit_hook(self.returncode) return self.postinst_failure = merge_task.postinst_failure @@ -55,5 +57,19 @@ class EbuildMerge(CompositeTask): logger.log(" ::: completed emerge (%s of %s) %s to %s" % \ (pkg_count.curval, pkg_count.maxval, pkg.cpv, pkg.root)) - self.exit_hook(self) - self.wait() + self._start_exit_hook(self.returncode) + + def _start_exit_hook(self, returncode): + """ + Start the exit hook, and set returncode after it completes. + """ + # The returncode will be set after exit hook is complete. + self.returncode = None + self._start_task( + AsyncTaskFuture(future=self.exit_hook(self)), + functools.partial(self._exit_hook_exit, returncode)) + + def _exit_hook_exit(self, returncode, task): + self._assert_current(task) + self.returncode = returncode + self._async_wait()