aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2024-10-28 13:13:38 -0700
committerZac Medico <zmedico@gentoo.org>2024-10-28 13:13:38 -0700
commit69c8459835261b03af71c74ad75596c9425bcb0b (patch)
tree3c8dc5b80921d54542cb5b61cc7c9eff163c075d
parentbinarytree: Fix _inject_repo_revisions to ignore remote packages (diff)
downloadportage-69c8459835261b03af71c74ad75596c9425bcb0b.tar.gz
portage-69c8459835261b03af71c74ad75596c9425bcb0b.tar.bz2
portage-69c8459835261b03af71c74ad75596c9425bcb0b.zip
Handle python3.14 ChildWatcher changes
Bug: https://bugs.gentoo.org/941955 Signed-off-by: Zac Medico <zmedico@gentoo.org>
-rw-r--r--lib/portage/tests/util/futures/asyncio/test_policy_wrapper_recursion.py7
-rw-r--r--lib/portage/util/_eventloop/asyncio_event_loop.py13
-rw-r--r--lib/portage/util/futures/unix_events.py8
3 files changed, 15 insertions, 13 deletions
diff --git a/lib/portage/tests/util/futures/asyncio/test_policy_wrapper_recursion.py b/lib/portage/tests/util/futures/asyncio/test_policy_wrapper_recursion.py
index 3896f91ac..d22d0241e 100644
--- a/lib/portage/tests/util/futures/asyncio/test_policy_wrapper_recursion.py
+++ b/lib/portage/tests/util/futures/asyncio/test_policy_wrapper_recursion.py
@@ -1,4 +1,4 @@
-# Copyright 2018 Gentoo Foundation
+# Copyright 2018-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
import asyncio
@@ -17,7 +17,8 @@ class PolicyWrapperRecursionTestCase(TestCase):
with self.assertRaises(NotImplementedError):
asyncio.get_event_loop()
- with self.assertRaises(NotImplementedError):
- asyncio.get_child_watcher()
+ if hasattr(asyncio, "get_child_watcher"):
+ with self.assertRaises(NotImplementedError):
+ asyncio.get_child_watcher()
finally:
asyncio.set_event_loop_policy(initial_policy)
diff --git a/lib/portage/util/_eventloop/asyncio_event_loop.py b/lib/portage/util/_eventloop/asyncio_event_loop.py
index c69e5c2f0..ad1dd387b 100644
--- a/lib/portage/util/_eventloop/asyncio_event_loop.py
+++ b/lib/portage/util/_eventloop/asyncio_event_loop.py
@@ -6,12 +6,16 @@ import signal
import asyncio as _real_asyncio
from asyncio.events import AbstractEventLoop as _AbstractEventLoop
-from asyncio.unix_events import ThreadedChildWatcher
try:
- from asyncio.unix_events import PidfdChildWatcher
+ from asyncio.unix_events import _ThreadedChildWatcher as ThreadedChildWatcher
except ImportError:
- PidfdChildWatcher = None
+ from asyncio.unix_events import ThreadedChildWatcher
+
+try:
+ from asyncio.unix_events import _PidfdChildWatcher as PidfdChildWatcher
+except ImportError:
+ from asyncio.unix_events import PidfdChildWatcher
import portage
@@ -123,7 +127,8 @@ class AsyncioEventLoop(_AbstractEventLoop):
else:
watcher = ThreadedChildWatcher()
- watcher.attach_loop(self._loop)
+ if hasattr(watcher, "attach_loop"):
+ watcher.attach_loop(self._loop)
self._child_watcher = _ChildWatcherThreadSafetyWrapper(self, watcher)
return self._child_watcher
diff --git a/lib/portage/util/futures/unix_events.py b/lib/portage/util/futures/unix_events.py
index 374497010..370cafb00 100644
--- a/lib/portage/util/futures/unix_events.py
+++ b/lib/portage/util/futures/unix_events.py
@@ -1,14 +1,10 @@
-# Copyright 2018-2021 Gentoo Authors
+# Copyright 2018-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
-__all__ = (
- "AbstractChildWatcher",
- "DefaultEventLoopPolicy",
-)
+__all__ = ("DefaultEventLoopPolicy",)
import asyncio as _real_asyncio
from asyncio import events
-from asyncio.unix_events import AbstractChildWatcher
import fcntl
import os