diff options
author | 2024-02-23 19:52:47 -0800 | |
---|---|---|
committer | 2024-02-23 20:23:27 -0800 | |
commit | acb69a6f234bd412e95e76f5c1db1b1f5b8e1dc5 (patch) | |
tree | 350abfeaa695291fd3e77de5f06d43b30f50dfb6 | |
parent | Fix python 3.9 CI jobs since 92ff02b9189f (diff) | |
download | portage-acb69a6f234bd412e95e76f5c1db1b1f5b8e1dc5.tar.gz portage-acb69a6f234bd412e95e76f5c1db1b1f5b8e1dc5.tar.bz2 portage-acb69a6f234bd412e95e76f5c1db1b1f5b8e1dc5.zip |
SchedulerInterface/PollScheduler: Add _loop property
This allows async_aux_get to easily verify the identity of
the underlying loop so that this assertion will not fail:
_start_with_metadata
(settings.configdict["pkg"]["SRC_URI"],) = aux_get_task.future.result()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/portage/dbapi/porttree.py", line 786, in async_aux_get
raise AssertionError(
AssertionError: async_aux_get called from thread <_MainThread(MainThread, started 281473559502880)> with loop <_emerge.Scheduler.Scheduler._iface_class object at 0xffff8e3a8840>
Terminated
Fixes: 389bb304abf5 ("async_aux_get: Use EbuildMetadataPhase deallocate_config future")
Bug: https://bugs.gentoo.org/925333
Signed-off-by: Zac Medico <zmedico@gentoo.org>
-rw-r--r-- | lib/_emerge/PollScheduler.py | 9 | ||||
-rw-r--r-- | lib/portage/dbapi/porttree.py | 2 | ||||
-rw-r--r-- | lib/portage/tests/ebuild/test_doebuild_spawn.py | 3 | ||||
-rw-r--r-- | lib/portage/tests/ebuild/test_ipc_daemon.py | 3 | ||||
-rw-r--r-- | lib/portage/util/_async/SchedulerInterface.py | 9 |
5 files changed, 21 insertions, 5 deletions
diff --git a/lib/_emerge/PollScheduler.py b/lib/_emerge/PollScheduler.py index e5dffd8af..b5bfd20b7 100644 --- a/lib/_emerge/PollScheduler.py +++ b/lib/_emerge/PollScheduler.py @@ -1,4 +1,4 @@ -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import threading @@ -39,6 +39,13 @@ class PollScheduler: self._event_loop, is_background=self._is_background ) + @property + def _loop(self): + """ + Returns the real underlying asyncio loop. + """ + return self._event_loop._loop + def _is_background(self): return self._background diff --git a/lib/portage/dbapi/porttree.py b/lib/portage/dbapi/porttree.py index 4eebe1183..de6aa5c82 100644 --- a/lib/portage/dbapi/porttree.py +++ b/lib/portage/dbapi/porttree.py @@ -775,7 +775,7 @@ class portdbapi(dbapi): try: if ( threading.current_thread() is threading.main_thread() - and loop is asyncio._safe_loop() + and loop._loop is asyncio._safe_loop()._loop ): # In this case use self._doebuild_settings_lock to manage concurrency. deallocate_config = loop.create_future() diff --git a/lib/portage/tests/ebuild/test_doebuild_spawn.py b/lib/portage/tests/ebuild/test_doebuild_spawn.py index 9fb2c7fdd..cac844f8f 100644 --- a/lib/portage/tests/ebuild/test_doebuild_spawn.py +++ b/lib/portage/tests/ebuild/test_doebuild_spawn.py @@ -1,4 +1,4 @@ -# Copyright 2010-2015 Gentoo Foundation +# Copyright 2010-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import textwrap @@ -86,6 +86,7 @@ class DoebuildSpawnTestCase(TestCase): open(os.path.join(settings["T"], "environment"), "wb").close() scheduler = SchedulerInterface(global_event_loop()) + self.assertTrue(scheduler._loop is global_event_loop()._loop) for phase in ("_internal_test",): # Test EbuildSpawnProcess by calling doebuild.spawn() with # returnpid=False. This case is no longer used by portage diff --git a/lib/portage/tests/ebuild/test_ipc_daemon.py b/lib/portage/tests/ebuild/test_ipc_daemon.py index 0beb69ddf..b8777fe94 100644 --- a/lib/portage/tests/ebuild/test_ipc_daemon.py +++ b/lib/portage/tests/ebuild/test_ipc_daemon.py @@ -1,4 +1,4 @@ -# Copyright 2010-2023 Gentoo Authors +# Copyright 2010-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import tempfile @@ -77,6 +77,7 @@ class IpcDaemonTestCase(TestCase): task_scheduler = TaskScheduler( iter([daemon, proc]), max_jobs=2, event_loop=event_loop ) + self.assertTrue(task_scheduler._loop is event_loop._loop) self.received_command = False diff --git a/lib/portage/util/_async/SchedulerInterface.py b/lib/portage/util/_async/SchedulerInterface.py index 43a42adff..485958491 100644 --- a/lib/portage/util/_async/SchedulerInterface.py +++ b/lib/portage/util/_async/SchedulerInterface.py @@ -1,4 +1,4 @@ -# Copyright 2012-2021 Gentoo Authors +# Copyright 2012-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import gzip @@ -49,6 +49,13 @@ class SchedulerInterface(SlotObject): for k in self._event_loop_attrs: setattr(self, k, getattr(event_loop, k)) + @property + def _loop(self): + """ + Returns the real underlying asyncio loop. + """ + return self._event_loop._loop + @staticmethod def _return_false(): return False |