public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: lib/portage/, lib/portage/util/futures/_asyncio/
@ 2024-10-22 21:29 Zac Medico
  0 siblings, 0 replies; only message in thread
From: Zac Medico @ 2024-10-22 21:29 UTC (permalink / raw
  To: gentoo-commits

commit:     7218c9cea6185c82fbc1719489a2d8e814d05ff1
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 22 01:01:57 2024 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Oct 22 21:27:18 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=7218c9ce

Fix asyncio.iscoroutinefunction DeprecationWarning in Python 3.14.0a1

DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead

Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/process.py                        | 7 ++++++-
 lib/portage/util/futures/_asyncio/__init__.py | 6 +++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/portage/process.py b/lib/portage/process.py
index e6f6feb357..a66b6a5410 100644
--- a/lib/portage/process.py
+++ b/lib/portage/process.py
@@ -23,6 +23,11 @@ from dataclasses import dataclass
 from functools import lru_cache, partial
 from typing import Any, Optional, Callable, Union
 
+try:
+    from inspect import iscoroutinefunction
+except ImportError:
+    iscoroutinefunction = _asyncio.iscoroutinefunction
+
 from portage import os
 from portage import _encodings
 from portage import _unicode_encode
@@ -203,7 +208,7 @@ def atexit_register(func, *args, **kargs):
     manually by calling the run_exitfuncs() function in this module."""
     # The internal asyncio wrapper module would trigger a circular import
     # if used here.
-    if _asyncio.iscoroutinefunction(func):
+    if iscoroutinefunction(func):
         # Add this coroutine function to the exit handlers for the loop
         # which is associated with the current thread.
         global_event_loop()._coroutine_exithandlers.append((func, args, kargs))

diff --git a/lib/portage/util/futures/_asyncio/__init__.py b/lib/portage/util/futures/_asyncio/__init__.py
index 4cf337998c..ea67adcae4 100644
--- a/lib/portage/util/futures/_asyncio/__init__.py
+++ b/lib/portage/util/futures/_asyncio/__init__.py
@@ -38,13 +38,17 @@ from asyncio import (
     FIRST_EXCEPTION,
     Future,
     InvalidStateError,
-    iscoroutinefunction,
     Lock as _Lock,
     shield,
     TimeoutError,
     wait_for,
 )
 
+try:
+    from inspect import iscoroutinefunction
+except ImportError:
+    iscoroutinefunction = _asyncio.iscoroutinefunction
+
 import threading
 from typing import Optional
 


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-10-22 21:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-22 21:29 [gentoo-commits] proj/portage:master commit in: lib/portage/, lib/portage/util/futures/_asyncio/ Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox