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 B5C2F138331 for ; Fri, 20 Apr 2018 16:18:34 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C61CBE0938; Fri, 20 Apr 2018 16:18:33 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (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 86E74E0938 for ; Fri, 20 Apr 2018 16:18:33 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (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 F24F7335C78 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 0CF3727C 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: <1524239399.5ca8ef781952d8148c21a1f5369c6d04335a9208.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/EbuildBuild.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 5ca8ef781952d8148c21a1f5369c6d04335a9208 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: 3c114701-21e6-4436-816a-41e03b4206a4 X-Archives-Hash: 8f877e73576f55adf1fa9082dde0faa7 commit: 5ca8ef781952d8148c21a1f5369c6d04335a9208 Author: Zac Medico gentoo org> AuthorDate: Thu Apr 19 16:18:36 2018 +0000 Commit: Zac Medico gentoo org> CommitDate: Fri Apr 20 15:49:59 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=5ca8ef78 EbuildBuild: 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/EbuildBuild.py | 52 ++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/pym/_emerge/EbuildBuild.py b/pym/_emerge/EbuildBuild.py index 48f470483..f1a2103a3 100644 --- a/pym/_emerge/EbuildBuild.py +++ b/pym/_emerge/EbuildBuild.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals +import functools import io import _emerge.emergelog @@ -23,6 +24,8 @@ from portage import _encodings, _unicode_decode, _unicode_encode, os from portage.package.ebuild.digestcheck import digestcheck from portage.package.ebuild.doebuild import _check_temp_dir from portage.package.ebuild._spawn_nofetch import SpawnNofetchWithoutBuilddir +from portage.util._async.AsyncTaskFuture import AsyncTaskFuture + class EbuildBuild(CompositeTask): @@ -185,8 +188,7 @@ class EbuildBuild(CompositeTask): def _pre_clean_exit(self, pre_clean_phase): if self._default_exit(pre_clean_phase) != os.EX_OK: - self._unlock_builddir() - self.wait() + self._async_unlock_builddir(returncode=self.returncode) return # for log handling @@ -209,10 +211,7 @@ class EbuildBuild(CompositeTask): msg_lines.append(msg) fetcher._eerror(msg_lines) portage.elog.elog_process(self.pkg.cpv, self.settings) - self.returncode = 1 - self._current_task = None - self._unlock_builddir() - self.wait() + self._async_unlock_builddir(returncode=1) return if already_fetched: @@ -283,8 +282,7 @@ class EbuildBuild(CompositeTask): if 'fetch' not in self.pkg.restrict and \ 'nofetch' not in self.pkg.defined_phases: - self._unlock_builddir() - self.wait() + self._async_unlock_builddir(returncode=self.returncode) return self.returncode = None @@ -294,18 +292,32 @@ class EbuildBuild(CompositeTask): def _nofetch_exit(self, nofetch_phase): self._final_exit(nofetch_phase) - self._unlock_builddir() - self.returncode = 1 - self.wait() + self._async_unlock_builddir(returncode=1) - def _unlock_builddir(self): + 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 portage.elog.elog_process(self.pkg.cpv, self.settings) - self._build_dir.unlock() + self._start_task( + AsyncTaskFuture(future=self._build_dir.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 _build_exit(self, build): if self._default_exit(build) != os.EX_OK: - self._unlock_builddir() - self.wait() + self._async_unlock_builddir(returncode=self.returncode) return buildpkg = self._buildpkg @@ -370,8 +382,7 @@ class EbuildBuild(CompositeTask): """ if self._default_exit(packager) != os.EX_OK: - self._unlock_builddir() - self.wait() + self._async_unlock_builddir(returncode=self.returncode) return if self.opts.buildpkgonly: @@ -425,8 +436,9 @@ class EbuildBuild(CompositeTask): def _clean_exit(self, clean_phase): if self._final_exit(clean_phase) != os.EX_OK or \ self.opts.buildpkgonly: - self._unlock_builddir() - self.wait() + self._async_unlock_builddir(returncode=self.returncode) + else: + self.wait() def create_install_task(self): """ @@ -461,4 +473,4 @@ class EbuildBuild(CompositeTask): return task def _install_exit(self, task): - self._unlock_builddir() + self._async_unlock_builddir()