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 338BD1382C5 for ; Fri, 20 Apr 2018 16:18:35 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 33194E0937; Fri, 20 Apr 2018 16:18:33 +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 F14CBE0937 for ; Fri, 20 Apr 2018 16:18:32 +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 A9B7F335C7A for ; Fri, 20 Apr 2018 16:18:31 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2062628E for ; Fri, 20 Apr 2018 16:18:30 +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: <1524239419.7f7174748266197aa3112f7c6c93a255d1d18ed0.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/PackageUninstall.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 7f7174748266197aa3112f7c6c93a255d1d18ed0 X-VCS-Branch: master Date: Fri, 20 Apr 2018 16:18:30 +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: 54df8c34-829c-4f3d-9e0b-70f61eaa3a25 X-Archives-Hash: 88cab2211256014a047a938b60cd70a5 commit: 7f7174748266197aa3112f7c6c93a255d1d18ed0 Author: Zac Medico gentoo org> AuthorDate: Fri Apr 20 04:49:25 2018 +0000 Commit: Zac Medico gentoo org> CommitDate: Fri Apr 20 15:50:19 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=7f717474 PackageUninstall: use async_unlock (bug 614108) Add an _async_unlock_builddir method which accepts a returncode parameter for cases where it should set the returncode and notify exit listeners. Bug: https://bugs.gentoo.org/614108 pym/_emerge/PackageUninstall.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/pym/_emerge/PackageUninstall.py b/pym/_emerge/PackageUninstall.py index 16c2f749b..8f19e38e4 100644 --- a/pym/_emerge/PackageUninstall.py +++ b/pym/_emerge/PackageUninstall.py @@ -1,11 +1,13 @@ # Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +import functools import logging import portage from portage import os from portage.dbapi._MergeProcess import MergeProcess from portage.exception import UnsupportedAPIException +from portage.util._async.AsyncTaskFuture import AsyncTaskFuture from _emerge.EbuildBuildDir import EbuildBuildDir from _emerge.emergelog import emergelog from _emerge.CompositeTask import CompositeTask @@ -65,9 +67,7 @@ class PackageUninstall(CompositeTask): writemsg_level=self._writemsg_level) if retval != os.EX_OK: - self._builddir_lock.unlock() - self.returncode = retval - self._async_wait() + self._async_unlock_builddir(returncode=retval) return self._writemsg_level(">>> Unmerging %s...\n" % (self.pkg.cpv,), @@ -90,8 +90,27 @@ class PackageUninstall(CompositeTask): else: self._emergelog(" >>> unmerge success: %s" % (self.pkg.cpv,)) self.world_atom(self.pkg) - self._builddir_lock.unlock() - self.wait() + self._async_unlock_builddir(returncode=self.returncode) + + def _async_unlock_builddir(self, returncode=None): + """ + Release the lock asynchronously, and if a returncode parameter + is given then set self.returncode and notify exit listeners. + """ + if returncode is not None: + # The returncode will be set after unlock is complete. + self.returncode = None + self._start_task( + AsyncTaskFuture(future=self._builddir_lock.async_unlock()), + functools.partial(self._unlock_builddir_exit, returncode=returncode)) + + def _unlock_builddir_exit(self, unlock_task, returncode=None): + self._assert_current(unlock_task) + # Normally, async_unlock should not raise an exception here. + unlock_task.future.result() + if returncode is not None: + self.returncode = returncode + self._async_wait() def _emergelog(self, msg): emergelog("notitles" not in self.settings.features, msg)