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 C6E94138331 for ; Mon, 23 Apr 2018 18:52:41 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D8202E0AB9; Mon, 23 Apr 2018 18:52:40 +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 A7EC0E0AB9 for ; Mon, 23 Apr 2018 18:52:40 +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 CD6DE335C7A for ; Mon, 23 Apr 2018 18:52:39 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 172F6296 for ; Mon, 23 Apr 2018 18:52:38 +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: <1524508777.9596fc68bf13b5e8f44b522d2b2e9c303615462f.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/EbuildFetcher.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 9596fc68bf13b5e8f44b522d2b2e9c303615462f X-VCS-Branch: master Date: Mon, 23 Apr 2018 18:52:38 +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: 9c47bdb3-bbc9-4853-8dda-7aa641e570b4 X-Archives-Hash: 25c5ec1dfb76445a7e2df14a16a13dec commit: 9596fc68bf13b5e8f44b522d2b2e9c303615462f Author: Zac Medico gentoo org> AuthorDate: Sun Apr 22 21:18:53 2018 +0000 Commit: Zac Medico gentoo org> CommitDate: Mon Apr 23 18:39:37 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=9596fc68 EbuildFetcher: add _async_uri_map method (bug 653810) Add an _async_uri_map method to replace the synchronous _get_uri_map method. This will be used to prevent event loop recursion. Bug: https://bugs.gentoo.org/653810 Reviewed-by: Brian Dolbec gentoo.org> pym/_emerge/EbuildFetcher.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/pym/_emerge/EbuildFetcher.py b/pym/_emerge/EbuildFetcher.py index 81eeb6dcd..1f574740b 100644 --- a/pym/_emerge/EbuildFetcher.py +++ b/pym/_emerge/EbuildFetcher.py @@ -49,7 +49,7 @@ class _EbuildFetcherProcess(ForkProcess): "pkg", "prefetch", "_digests", "_manifest", "_settings", "_uri_map") def already_fetched(self, settings): - uri_map = self._get_uri_map() + uri_map = self.scheduler.run_until_complete(self._async_uri_map()) if not uri_map: return True @@ -125,7 +125,7 @@ class _EbuildFetcherProcess(ForkProcess): ebuild_path = self._get_ebuild_path() try: - uri_map = self._get_uri_map() + uri_map = self.scheduler.run_until_complete(self._async_uri_map()) except portage.exception.InvalidDependString as e: msg_lines = [] msg = "Fetch failed for '%s' due to invalid SRC_URI: %s" % \ @@ -210,21 +210,34 @@ class _EbuildFetcherProcess(ForkProcess): self._digests = self._get_manifest().getTypeDigests("DIST") return self._digests - def _get_uri_map(self): + def _async_uri_map(self): """ - This can raise InvalidDependString from portdbapi.getFetchMap(). + This calls the portdbapi.async_fetch_map method and returns the + resulting Future (may contain InvalidDependString exception). """ if self._uri_map is not None: - return self._uri_map + result = self.scheduler.create_future() + result.set_result(self._uri_map) + return result + pkgdir = os.path.dirname(self._get_ebuild_path()) mytree = os.path.dirname(os.path.dirname(pkgdir)) use = None if not self.fetchall: use = self.pkg.use.enabled portdb = self.pkg.root_config.trees["porttree"].dbapi - self._uri_map = portdb.getFetchMap(self.pkg.cpv, + + def cache_result(result): + try: + self._uri_map = result.result() + except Exception: + # The caller handles this when it retrieves the result. + pass + + result = portdb.async_fetch_map(self.pkg.cpv, useflags=use, mytree=mytree) - return self._uri_map + result.add_done_callback(cache_result) + return result def _prefetch_size_ok(self, uri_map, settings, ebuild_path): distdir = settings["DISTDIR"]