1 |
Add an _async_uri_map method to replace the synchronous _get_uri_map |
2 |
method. This will be used to prevent event loop recursion. |
3 |
|
4 |
Bug: https://bugs.gentoo.org/653810 |
5 |
--- |
6 |
pym/_emerge/EbuildFetcher.py | 27 ++++++++++++++++++++------- |
7 |
1 file changed, 20 insertions(+), 7 deletions(-) |
8 |
|
9 |
diff --git a/pym/_emerge/EbuildFetcher.py b/pym/_emerge/EbuildFetcher.py |
10 |
index 81eeb6dcd..1f574740b 100644 |
11 |
--- a/pym/_emerge/EbuildFetcher.py |
12 |
+++ b/pym/_emerge/EbuildFetcher.py |
13 |
@@ -49,7 +49,7 @@ class _EbuildFetcherProcess(ForkProcess): |
14 |
"pkg", "prefetch", "_digests", "_manifest", "_settings", "_uri_map") |
15 |
|
16 |
def already_fetched(self, settings): |
17 |
- uri_map = self._get_uri_map() |
18 |
+ uri_map = self.scheduler.run_until_complete(self._async_uri_map()) |
19 |
if not uri_map: |
20 |
return True |
21 |
|
22 |
@@ -125,7 +125,7 @@ class _EbuildFetcherProcess(ForkProcess): |
23 |
ebuild_path = self._get_ebuild_path() |
24 |
|
25 |
try: |
26 |
- uri_map = self._get_uri_map() |
27 |
+ uri_map = self.scheduler.run_until_complete(self._async_uri_map()) |
28 |
except portage.exception.InvalidDependString as e: |
29 |
msg_lines = [] |
30 |
msg = "Fetch failed for '%s' due to invalid SRC_URI: %s" % \ |
31 |
@@ -210,21 +210,34 @@ class _EbuildFetcherProcess(ForkProcess): |
32 |
self._digests = self._get_manifest().getTypeDigests("DIST") |
33 |
return self._digests |
34 |
|
35 |
- def _get_uri_map(self): |
36 |
+ def _async_uri_map(self): |
37 |
""" |
38 |
- This can raise InvalidDependString from portdbapi.getFetchMap(). |
39 |
+ This calls the portdbapi.async_fetch_map method and returns the |
40 |
+ resulting Future (may contain InvalidDependString exception). |
41 |
""" |
42 |
if self._uri_map is not None: |
43 |
- return self._uri_map |
44 |
+ result = self.scheduler.create_future() |
45 |
+ result.set_result(self._uri_map) |
46 |
+ return result |
47 |
+ |
48 |
pkgdir = os.path.dirname(self._get_ebuild_path()) |
49 |
mytree = os.path.dirname(os.path.dirname(pkgdir)) |
50 |
use = None |
51 |
if not self.fetchall: |
52 |
use = self.pkg.use.enabled |
53 |
portdb = self.pkg.root_config.trees["porttree"].dbapi |
54 |
- self._uri_map = portdb.getFetchMap(self.pkg.cpv, |
55 |
+ |
56 |
+ def cache_result(result): |
57 |
+ try: |
58 |
+ self._uri_map = result.result() |
59 |
+ except Exception: |
60 |
+ # The caller handles this when it retrieves the result. |
61 |
+ pass |
62 |
+ |
63 |
+ result = portdb.async_fetch_map(self.pkg.cpv, |
64 |
useflags=use, mytree=mytree) |
65 |
- return self._uri_map |
66 |
+ result.add_done_callback(cache_result) |
67 |
+ return result |
68 |
|
69 |
def _prefetch_size_ok(self, uri_map, settings, ebuild_path): |
70 |
distdir = settings["DISTDIR"] |
71 |
-- |
72 |
2.13.6 |