Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: lib/_emerge/
Date: Sat, 01 May 2021 22:47:42
Message-Id: 1619908659.bfe334d0293e12952f61c3131339f9dcd2bb6bd0.zmedico@gentoo
1 commit: bfe334d0293e12952f61c3131339f9dcd2bb6bd0
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Sat May 1 22:35:55 2021 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Sat May 1 22:37:39 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=bfe334d0
7
8 _run_pkg_pretend: Use async and await syntax
9
10 Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
11
12 lib/_emerge/Scheduler.py | 26 ++++++++++++--------------
13 1 file changed, 12 insertions(+), 14 deletions(-)
14
15 diff --git a/lib/_emerge/Scheduler.py b/lib/_emerge/Scheduler.py
16 index 656d382dd..d3528ee68 100644
17 --- a/lib/_emerge/Scheduler.py
18 +++ b/lib/_emerge/Scheduler.py
19 @@ -25,7 +25,6 @@ from portage._sets import SETPREFIX
20 from portage._sets.base import InternalPackageSet
21 from portage.util import ensure_dirs, writemsg, writemsg_level
22 from portage.util.futures import asyncio
23 -from portage.util.futures.compat_coroutine import coroutine, coroutine_return
24 from portage.util.SlotObject import SlotObject
25 from portage.util._async.SchedulerInterface import SchedulerInterface
26 from portage.package.ebuild.digestcheck import digestcheck
27 @@ -767,8 +766,7 @@ class Scheduler(PollScheduler):
28
29 return prefetcher
30
31 - @coroutine
32 - def _run_pkg_pretend(self, loop=None):
33 + async def _run_pkg_pretend(self, loop=None):
34 """
35 Since pkg_pretend output may be important, this method sends all
36 output directly to stdout (regardless of options like --quiet or
37 @@ -805,7 +803,7 @@ class Scheduler(PollScheduler):
38 # Get required SRC_URI metadata (it's not cached in x.metadata
39 # because some packages have an extremely large SRC_URI value).
40 portdb = root_config.trees["porttree"].dbapi
41 - (settings.configdict["pkg"]["SRC_URI"],) = yield portdb.async_aux_get(
42 + (settings.configdict["pkg"]["SRC_URI"],) = await portdb.async_aux_get(
43 x.cpv, ["SRC_URI"], myrepo=x.repo, loop=loop
44 )
45
46 @@ -825,7 +823,7 @@ class Scheduler(PollScheduler):
47 settings["PORTAGE_BUILDDIR"] = build_dir_path
48 build_dir = EbuildBuildDir(scheduler=sched_iface,
49 settings=settings)
50 - yield build_dir.async_lock()
51 + await build_dir.async_lock()
52 current_task = None
53
54 try:
55 @@ -851,7 +849,7 @@ class Scheduler(PollScheduler):
56 phase='clean', scheduler=sched_iface, settings=settings)
57 current_task = clean_phase
58 clean_phase.start()
59 - yield clean_phase.async_wait()
60 + await clean_phase.async_wait()
61
62 if x.built:
63 tree = "bintree"
64 @@ -870,7 +868,7 @@ class Scheduler(PollScheduler):
65 # handles fetch, verification, and the
66 # bintree.inject call which moves the file.
67 fetched = fetcher.pkg_path
68 - if (yield fetcher.async_wait()) != os.EX_OK:
69 + if await fetcher.async_wait() != os.EX_OK:
70 failures += 1
71 self._record_pkg_failure(x, settings, fetcher.returncode)
72 continue
73 @@ -883,7 +881,7 @@ class Scheduler(PollScheduler):
74 scheduler=sched_iface, _pkg_path=filename)
75 current_task = verifier
76 verifier.start()
77 - if (yield verifier.async_wait()) != os.EX_OK:
78 + if await verifier.async_wait() != os.EX_OK:
79 failures += 1
80 self._record_pkg_failure(x, settings, verifier.returncode)
81 continue
82 @@ -893,7 +891,7 @@ class Scheduler(PollScheduler):
83
84 infloc = os.path.join(build_dir_path, "build-info")
85 ensure_dirs(infloc)
86 - yield bintree.dbapi.unpack_metadata(settings, infloc, loop=loop)
87 + await bintree.dbapi.unpack_metadata(settings, infloc, loop=loop)
88 ebuild_path = os.path.join(infloc, x.pf + ".ebuild")
89 settings.configdict["pkg"]["EMERGE_FROM"] = "binary"
90 settings.configdict["pkg"]["MERGE_TYPE"] = "binary"
91 @@ -927,7 +925,7 @@ class Scheduler(PollScheduler):
92
93 current_task = pretend_phase
94 pretend_phase.start()
95 - ret = yield pretend_phase.async_wait()
96 + ret = await pretend_phase.async_wait()
97 if ret != os.EX_OK:
98 failures += 1
99 self._record_pkg_failure(x, settings, ret)
100 @@ -942,14 +940,14 @@ class Scheduler(PollScheduler):
101 phase='clean', scheduler=sched_iface,
102 settings=settings)
103 clean_phase.start()
104 - yield clean_phase.async_wait()
105 + await clean_phase.async_wait()
106
107 - yield build_dir.async_unlock()
108 + await build_dir.async_unlock()
109 self._deallocate_config(settings)
110
111 if failures:
112 - return coroutine_return(FAILURE)
113 - coroutine_return(os.EX_OK)
114 + return FAILURE
115 + return os.EX_OK
116
117 def _record_pkg_failure(self, pkg, settings, ret):
118 """Record a package failure. This eliminates the package