aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2020-08-17 23:31:54 -0700
committerZac Medico <zmedico@gentoo.org>2020-08-18 21:01:46 -0700
commitdc7919541712d846574e6b7d672a3bed0ca7ef1a (patch)
tree0ffcad7512777d06609531883e0c985bcf39af61 /lib/_emerge
parentrepoman: Update for a repoman-3.0.0 release (diff)
downloadportage-dc7919541712d846574e6b7d672a3bed0ca7ef1a.tar.gz
portage-dc7919541712d846574e6b7d672a3bed0ca7ef1a.tar.bz2
portage-dc7919541712d846574e6b7d672a3bed0ca7ef1a.zip
coroutine: use explicit loop parameter (bug 737698)
In order to support local event loops within API functions like doebuild, use an explicit loop parameter when calling a coroutine. Internal code will now raise an AssertionError if the loop parameter is omitted for a coroutine, but API consumers may omit it. Bug: https://bugs.gentoo.org/737698 Signed-off-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to 'lib/_emerge')
-rw-r--r--lib/_emerge/Binpkg.py8
-rw-r--r--lib/_emerge/EbuildPhase.py16
-rw-r--r--lib/_emerge/Scheduler.py4
-rw-r--r--lib/_emerge/SequentialTaskQueue.py4
-rw-r--r--lib/_emerge/SpawnProcess.py5
5 files changed, 19 insertions, 18 deletions
diff --git a/lib/_emerge/Binpkg.py b/lib/_emerge/Binpkg.py
index b5a69f8e7..9d2909d42 100644
--- a/lib/_emerge/Binpkg.py
+++ b/lib/_emerge/Binpkg.py
@@ -250,11 +250,11 @@ class Binpkg(CompositeTask):
return
self._start_task(
- AsyncTaskFuture(future=self._unpack_metadata()),
+ AsyncTaskFuture(future=self._unpack_metadata(loop=self.scheduler)),
self._unpack_metadata_exit)
@coroutine
- def _unpack_metadata(self):
+ def _unpack_metadata(self, loop=None):
dir_path = self.settings['PORTAGE_BUILDDIR']
@@ -271,7 +271,7 @@ class Binpkg(CompositeTask):
portage.prepare_build_dirs(self.settings["ROOT"], self.settings, 1)
self._writemsg_level(">>> Extracting info\n")
- yield self._bintree.dbapi.unpack_metadata(self.settings, infloc)
+ yield self._bintree.dbapi.unpack_metadata(self.settings, infloc, loop=self.scheduler)
check_missing_metadata = ("CATEGORY", "PF")
for k, v in zip(check_missing_metadata,
self._bintree.dbapi.aux_get(self.pkg.cpv, check_missing_metadata)):
@@ -333,7 +333,7 @@ class Binpkg(CompositeTask):
self._start_task(
AsyncTaskFuture(future=self._bintree.dbapi.unpack_contents(
self.settings,
- self._image_dir)),
+ self._image_dir, loop=self.scheduler)),
self._unpack_contents_exit)
def _unpack_contents_exit(self, unpack_contents):
diff --git a/lib/_emerge/EbuildPhase.py b/lib/_emerge/EbuildPhase.py
index 4bc2749bd..e4c0428a6 100644
--- a/lib/_emerge/EbuildPhase.py
+++ b/lib/_emerge/EbuildPhase.py
@@ -70,11 +70,11 @@ class EbuildPhase(CompositeTask):
_locked_phases = ("setup", "preinst", "postinst", "prerm", "postrm")
def _start(self):
- future = asyncio.ensure_future(self._async_start(), loop=self.scheduler)
+ future = asyncio.ensure_future(self._async_start(loop=self.scheduler), loop=self.scheduler)
self._start_task(AsyncTaskFuture(future=future), self._async_start_exit)
@coroutine
- def _async_start(self):
+ def _async_start(self, loop=None):
need_builddir = self.phase not in EbuildProcess._phases_without_builddir
@@ -132,7 +132,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)
+ yield self._elog('einfo', msg, background=True, loop=self.scheduler)
if self.phase == 'package':
if 'PORTAGE_BINPKG_TMPFILE' not in self.settings:
@@ -403,7 +403,7 @@ class EbuildPhase(CompositeTask):
self.wait()
@coroutine
- def _elog(self, elog_funcname, lines, background=None):
+ def _elog(self, elog_funcname, lines, background=None, loop=None):
if background is None:
background = self.background
out = io.StringIO()
@@ -435,7 +435,7 @@ class EbuildPhase(CompositeTask):
log_file = build_logger.stdin
yield self.scheduler.async_output(msg, log_file=log_file,
- background=background)
+ background=background, loop=self.scheduler)
if build_logger is not None:
build_logger.stdin.close()
@@ -487,7 +487,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 = self._soname_deps_qa()
+ future = asyncio.ensure_future(self._soname_deps_qa(loop=self.scheduler), 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)
@@ -497,7 +497,7 @@ class _PostPhaseCommands(CompositeTask):
self._default_final_exit(task)
@coroutine
- def _soname_deps_qa(self):
+ def _soname_deps_qa(self, loop=None):
vardb = QueryCommand.get_db()[self.settings['EROOT']]['vartree'].dbapi
@@ -512,4 +512,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)
+ yield self.elog("eqawarn", qa_msg, loop=self.scheduler)
diff --git a/lib/_emerge/Scheduler.py b/lib/_emerge/Scheduler.py
index 2427d953c..a69421288 100644
--- a/lib/_emerge/Scheduler.py
+++ b/lib/_emerge/Scheduler.py
@@ -871,7 +871,7 @@ class Scheduler(PollScheduler):
infloc = os.path.join(build_dir_path, "build-info")
ensure_dirs(infloc)
self._sched_iface.run_until_complete(
- bintree.dbapi.unpack_metadata(settings, infloc))
+ bintree.dbapi.unpack_metadata(settings, infloc, loop=self._sched_iface))
ebuild_path = os.path.join(infloc, x.pf + ".ebuild")
settings.configdict["pkg"]["EMERGE_FROM"] = "binary"
settings.configdict["pkg"]["MERGE_TYPE"] = "binary"
@@ -1621,7 +1621,7 @@ class Scheduler(PollScheduler):
if (self._task_queues.merge and (self._schedule_merge_wakeup_task is None
or self._schedule_merge_wakeup_task.done())):
self._schedule_merge_wakeup_task = asyncio.ensure_future(
- self._task_queues.merge.wait(), loop=self._event_loop)
+ self._task_queues.merge.wait(loop=self._event_loop), loop=self._event_loop)
self._schedule_merge_wakeup_task.add_done_callback(
self._schedule_merge_wakeup)
diff --git a/lib/_emerge/SequentialTaskQueue.py b/lib/_emerge/SequentialTaskQueue.py
index 40590b76c..02fe19912 100644
--- a/lib/_emerge/SequentialTaskQueue.py
+++ b/lib/_emerge/SequentialTaskQueue.py
@@ -69,7 +69,7 @@ class SequentialTaskQueue(SlotObject):
task.cancel()
@coroutine
- def wait(self):
+ def wait(self, loop=None):
"""
Wait for the queue to become empty. This method is a coroutine.
"""
@@ -77,7 +77,7 @@ class SequentialTaskQueue(SlotObject):
task = next(iter(self.running_tasks), None)
if task is None:
# Wait for self.running_tasks to populate.
- yield asyncio.sleep(0)
+ yield asyncio.sleep(0, loop=loop)
else:
yield task.async_wait()
diff --git a/lib/_emerge/SpawnProcess.py b/lib/_emerge/SpawnProcess.py
index cea16df27..c43d60d3f 100644
--- a/lib/_emerge/SpawnProcess.py
+++ b/lib/_emerge/SpawnProcess.py
@@ -140,11 +140,12 @@ class SpawnProcess(SubProcess):
self._registered = True
self._main_task_cancel = functools.partial(self._main_cancel, build_logger, pipe_logger)
- self._main_task = asyncio.ensure_future(self._main(build_logger, pipe_logger), loop=self.scheduler)
+ self._main_task = asyncio.ensure_future(
+ self._main(build_logger, pipe_logger, loop=self.scheduler), loop=self.scheduler)
self._main_task.add_done_callback(self._main_exit)
@coroutine
- def _main(self, build_logger, pipe_logger):
+ def _main(self, build_logger, pipe_logger, loop=None):
try:
if pipe_logger.poll() is None:
yield pipe_logger.async_wait()