Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SchedulerInterface/PollScheduler: Add _loop property #1278

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/_emerge/PollScheduler.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -39,6 +39,13 @@ def __init__(self, main=False, event_loop=None):
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

Expand Down
2 changes: 1 addition & 1 deletion lib/_emerge/depgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ def _dynamic_deps_preload(self, fake_vartree):
ebuild_hash=ebuild_hash,
portdb=portdb,
repo_path=repo_path,
settings=portdb.doebuild_settings,
settings=settings,
deallocate_config=deallocate_config,
)
proc.addExitListener(self._dynamic_deps_proc_exit(pkg, fake_vartree))
Expand Down
2 changes: 1 addition & 1 deletion lib/portage/dbapi/porttree.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ async def async_aux_get(self, mycpv, mylist, mytree=None, myrepo=None, loop=None
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()
Expand Down
3 changes: 2 additions & 1 deletion lib/portage/tests/ebuild/test_doebuild_spawn.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -86,6 +86,7 @@ def testDoebuildSpawn(self):
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
Expand Down
3 changes: 2 additions & 1 deletion lib/portage/tests/ebuild/test_ipc_daemon.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -77,6 +77,7 @@ def testIpcDaemon(self):
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

Expand Down
9 changes: 8 additions & 1 deletion lib/portage/util/_async/SchedulerInterface.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -49,6 +49,13 @@ def __init__(self, event_loop, is_background=None, **kwargs):
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
Expand Down