aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2021-03-07 06:55:49 -0800
committerZac Medico <zmedico@gentoo.org>2021-03-07 07:12:42 -0800
commit77e545e0955930606eb7e73d3970d8c0706fd8a8 (patch)
tree95fa06785ebbc427a8601803eb2f34008a2fb0c8
parentBuildLogger: Use async and await syntax (diff)
downloadportage-77e545e0955930606eb7e73d3970d8c0706fd8a8.tar.gz
portage-77e545e0955930606eb7e73d3970d8c0706fd8a8.tar.bz2
portage-77e545e0955930606eb7e73d3970d8c0706fd8a8.zip
EbuildPhase: Use async and await syntax
Signed-off-by: Zac Medico <zmedico@gentoo.org>
-rw-r--r--lib/_emerge/EbuildPhase.py28
-rw-r--r--lib/portage/util/_async/SchedulerInterface.py10
2 files changed, 16 insertions, 22 deletions
diff --git a/lib/_emerge/EbuildPhase.py b/lib/_emerge/EbuildPhase.py
index e4c0428a6..26c770d29 100644
--- a/lib/_emerge/EbuildPhase.py
+++ b/lib/_emerge/EbuildPhase.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
import functools
@@ -21,7 +21,6 @@ from portage.util._dyn_libs.soname_deps_qa import (
)
from portage.package.ebuild.prepare_build_dirs import (_prepare_workdir,
_prepare_fake_distdir, _prepare_fake_filesdir)
-from portage.util.futures.compat_coroutine import coroutine
from portage.util import writemsg
from portage.util._async.AsyncTaskFuture import AsyncTaskFuture
from portage.util._async.BuildLogger import BuildLogger
@@ -70,11 +69,10 @@ class EbuildPhase(CompositeTask):
_locked_phases = ("setup", "preinst", "postinst", "prerm", "postrm")
def _start(self):
- future = asyncio.ensure_future(self._async_start(loop=self.scheduler), loop=self.scheduler)
+ future = asyncio.ensure_future(self._async_start(), loop=self.scheduler)
self._start_task(AsyncTaskFuture(future=future), self._async_start_exit)
- @coroutine
- def _async_start(self, loop=None):
+ async def _async_start(self):
need_builddir = self.phase not in EbuildProcess._phases_without_builddir
@@ -132,7 +130,7 @@ class EbuildPhase(CompositeTask):
# Force background=True for this header since it's intended
# for the log and it doesn't necessarily need to be visible
# elsewhere.
- yield self._elog('einfo', msg, background=True, loop=self.scheduler)
+ await self._elog('einfo', msg, background=True)
if self.phase == 'package':
if 'PORTAGE_BINPKG_TMPFILE' not in self.settings:
@@ -402,8 +400,7 @@ class EbuildPhase(CompositeTask):
self.returncode = 1
self.wait()
- @coroutine
- def _elog(self, elog_funcname, lines, background=None, loop=None):
+ async def _elog(self, elog_funcname, lines, background=None):
if background is None:
background = self.background
out = io.StringIO()
@@ -434,12 +431,12 @@ class EbuildPhase(CompositeTask):
_set_nonblocking(build_logger.stdin.fileno())
log_file = build_logger.stdin
- yield self.scheduler.async_output(msg, log_file=log_file,
- background=background, loop=self.scheduler)
+ await self.scheduler.async_output(msg, log_file=log_file,
+ background=background)
if build_logger is not None:
build_logger.stdin.close()
- yield build_logger.async_wait()
+ await build_logger.async_wait()
except asyncio.CancelledError:
if build_logger is not None:
build_logger.cancel()
@@ -487,7 +484,7 @@ class _PostPhaseCommands(CompositeTask):
if 'qa-unresolved-soname-deps' in self.settings.features:
# This operates on REQUIRES metadata generated by the above function call.
- future = asyncio.ensure_future(self._soname_deps_qa(loop=self.scheduler), loop=self.scheduler)
+ future = asyncio.ensure_future(self._soname_deps_qa(), loop=self.scheduler)
# If an unexpected exception occurs, then this will raise it.
future.add_done_callback(lambda future: future.cancelled() or future.result())
self._start_task(AsyncTaskFuture(future=future), self._default_final_exit)
@@ -496,12 +493,11 @@ class _PostPhaseCommands(CompositeTask):
else:
self._default_final_exit(task)
- @coroutine
- def _soname_deps_qa(self, loop=None):
+ async def _soname_deps_qa(self):
vardb = QueryCommand.get_db()[self.settings['EROOT']]['vartree'].dbapi
- all_provides = (yield self.scheduler.run_in_executor(ForkExecutor(loop=self.scheduler), _get_all_provides, vardb))
+ all_provides = (await self.scheduler.run_in_executor(ForkExecutor(loop=self.scheduler), _get_all_provides, vardb))
unresolved = _get_unresolved_soname_deps(os.path.join(self.settings['PORTAGE_BUILDDIR'], 'build-info'), all_provides)
@@ -512,4 +508,4 @@ class _PostPhaseCommands(CompositeTask):
qa_msg.extend("\t%s: %s" % (filename, " ".join(sorted(soname_deps)))
for filename, soname_deps in unresolved)
qa_msg.append("")
- yield self.elog("eqawarn", qa_msg, loop=self.scheduler)
+ await self.elog("eqawarn", qa_msg)
diff --git a/lib/portage/util/_async/SchedulerInterface.py b/lib/portage/util/_async/SchedulerInterface.py
index 2865266eb..c2d1be51f 100644
--- a/lib/portage/util/_async/SchedulerInterface.py
+++ b/lib/portage/util/_async/SchedulerInterface.py
@@ -1,4 +1,4 @@
-# Copyright 2012-2020 Gentoo Authors
+# Copyright 2012-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
import gzip
@@ -8,7 +8,6 @@ from portage import _encodings
from portage import _unicode_encode
from portage.util import writemsg_level
from portage.util.futures._asyncio.streams import _writer
-from portage.util.futures.compat_coroutine import coroutine
from ..SlotObject import SlotObject
class SchedulerInterface(SlotObject):
@@ -55,9 +54,8 @@ class SchedulerInterface(SlotObject):
def _return_false():
return False
- @coroutine
- def async_output(self, msg, log_file=None, background=None,
- level=0, noiselevel=-1, loop=None):
+ async def async_output(self, msg, log_file=None, background=None,
+ level=0, noiselevel=-1):
"""
Output a msg to stdio (if not in background) and to a log file
if provided.
@@ -81,7 +79,7 @@ class SchedulerInterface(SlotObject):
writemsg_level(msg, level=level, noiselevel=noiselevel)
if log_file is not None:
- yield _writer(log_file, _unicode_encode(msg), loop=loop)
+ await _writer(log_file, _unicode_encode(msg))
def output(self, msg, log_path=None, background=None,
level=0, noiselevel=-1):