Bug 2356166 - python-pymongo fails to build with Python 3.14: DeprecationWarning: 'asyncio.iscoroutinefunction' and 'asyncio.get_event_loop_policy' is deprecated and slated for removal in Python 3.16
Summary: python-pymongo fails to build with Python 3.14: DeprecationWarning: 'asyncio....
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-pymongo
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Alan Pevec
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 2372065 (view as bug list)
Depends On:
Blocks: PYTHON3.14 F43FTBFS, RAWHIDEFTBFS F43FailsToInstall, RAWHIDEFailsToInstall 2371785 2372070 2372073 2372120 2371695 2371769 2371794 2371907 2371908 2371961 2371988 2372056
TreeView+ depends on / blocked
 
Reported: 2025-03-31 08:51 UTC by Karolina Surma
Modified: 2025-06-21 22:09 UTC (History)
11 users (show)

Fixed In Version: python-pymongo-4.13.1-1.fc43
Clone Of:
Environment:
Last Closed: 2025-06-21 22:09:20 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Karolina Surma 2025-03-31 08:51:57 UTC
python-pymongo fails to build with Python 3.14.0a6.

ImportError while loading conftest '/builddir/build/BUILD/python-pymongo-4.9.1-build/mongo-python-driver-4.9.1/test/conftest.py'.
test/__init__.py:1131: in <module>
    class IntegrationTest(PyMongoTestCase):
test/__init__.py:1153: in IntegrationTest
    @client_context.require_connection
test/__init__.py:502: in require_connection
    return self._require(
test/__init__.py:491: in _require
    return make_wrapper(func)
test/__init__.py:455: in make_wrapper
    if iscoroutinefunction(f):
/usr/lib64/python3.14/asyncio/coroutines.py:23: in iscoroutinefunction
    warnings._deprecated("asyncio.iscoroutinefunction",
/usr/lib64/python3.14/warnings.py:677: in _deprecated
    warn(msg, DeprecationWarning, stacklevel=3)
E   DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead


When this is mitigated, another DeprecationWarning is all over the place: event_loop_policy fixture directly uses asyncio.get_event_loop_policy().

___________ ERROR at setup of TestServerApi.test_command_options_txn ___________

    @pytest.fixture(scope="session")
    def event_loop_policy():
        # The default asyncio loop implementation on Windows
        # has issues with sharing sockets across loops (https://github.com/python/cpython/issues/122240)
        # We explicitly use a different loop implementation here to prevent that issue
        if sys.platform == "win32":
            # Needed for Python 3.8.
            asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
            return asyncio.WindowsSelectorEventLoopPolicy()  # type: ignore[attr-defined]
    
>       return asyncio.get_event_loop_policy()

test/conftest.py:22: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib64/python3.14/asyncio/events.py:806: in get_event_loop_policy
    warnings._deprecated('asyncio.get_event_loop_policy', remove=(3, 16))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'asyncio.get_event_loop_policy'
message = '{name!r} is deprecated and slated for removal in Python {remove}'

    def _deprecated(name, message=_DEPRECATED_MSG, *, remove, _version=sys.version_info):
        """Warn that *name* is deprecated or should be removed.
    
        RuntimeError is raised if *remove* specifies a major/minor tuple older than
        the current Python version or the same version but past the alpha.
    
        The *message* argument is formatted with *name* and *remove* as a Python
        version tuple (e.g. (3, 11)).
    
        """
        remove_formatted = f"{remove[0]}.{remove[1]}"
        if (_version[:2] > remove) or (_version[:2] == remove and _version[3] != "alpha"):
            msg = f"{name!r} was slated for removal after Python {remove_formatted} alpha"
            raise RuntimeError(msg)
        else:
            msg = message.format(name=name, remove=remove_formatted)
>           warn(msg, DeprecationWarning, stacklevel=3)
E           DeprecationWarning: 'asyncio.get_event_loop_policy' is deprecated and slated for removal in Python 3.16

According to https://docs.python.org/dev/whatsnew/3.14.html#id3

asyncio policy system is deprecated and will be removed in Python 3.16. In particular, the following classes and functions are deprecated:
asyncio.AbstractEventLoopPolicy
asyncio.DefaultEventLoopPolicy
asyncio.WindowsSelectorEventLoopPolicy
asyncio.WindowsProactorEventLoopPolicy
asyncio.get_event_loop_policy()
asyncio.set_event_loop_policy()
asyncio.set_event_loop()
Users should use asyncio.run() or asyncio.Runner with loop_factory to use the desired event loop implementation.)


https://docs.python.org/3.14/whatsnew/3.14.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.14/fedora-rawhide-x86_64/08837401-python-pymongo/

For all our attempts to build python-pymongo with Python 3.14, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14/package/python-pymongo/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.14:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14/

Let us know here if you have any questions.

Python 3.14 is planned to be included in Fedora 43.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.14.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Ben Beasley 2025-06-05 11:58:37 UTC
I tried asking pytest not to treat warnings as errors, as follows:

diff --git a/python-pymongo.spec b/python-pymongo.spec
index 3823dcf..fcbb870 100644
--- a/python-pymongo.spec
+++ b/python-pymongo.spec
@@ -15,6 +15,7 @@ Source0:        %{giturl}/archive/%{version}/pymongo-%{version}.tar.gz
 
 BuildRequires:  gcc
 BuildRequires:  make
+BuildRequires:  tomcli
 BuildRequires:  python3-devel
 %if 0%{docs}
 BuildRequires:  python3-furo
@@ -99,6 +100,10 @@ contains the python3 version of this module.
 # Permit use of pytest-asyncio 0.23
 sed -i '/pytest-asyncio/s/0\.24\.0/0.23.0/' requirements/test.txt
 
+# filterwarnings = ["error"] is too strict for downstream packaging
+tomcli set pyproject.toml lists delitem \
+  tool.pytest.ini_options.filterwarnings error
+
 
 %generate_buildrequires
 %ifarch %{ix86}

With that change, I encountered a large number of ERRORs in the tests:

= 947 passed, 3123 skipped, 816 deselected, 1397 warnings, 570 errors in 60.47s (0:01:00) =

The most popular kind of error – possibly the only kind of error? – ended with:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <[AttributeError("'Condition' object has no attribute '_waiters'") raised in repr()] Condition object at 0x7f6060239e50>
lock = <pymongo.lock._ALock object at 0x7f6060239d10>

    def __init__(self, lock=None):
        if lock is None:
            lock = RLock()
        self._lock = lock
        # Export the lock's acquire(), release(), and locked() methods
        self.acquire = lock.acquire
        self.release = lock.release
>       self.locked = lock.locked
E       AttributeError: '_ALock' object has no attribute 'locked'

/usr/lib64/python3.14/threading.py:297: AttributeError

Comment 2 Karolina Surma 2025-06-11 16:02:46 UTC
*** Bug 2372065 has been marked as a duplicate of this bug. ***

Comment 4 Fedora Fails To Install 2025-06-20 19:52:05 UTC
Hello,

Please note that this comment was generated automatically by https://pagure.io/releng/blob/main/f/scripts/ftbfs-fti/follow-policy.py
If you feel that this output has mistakes, please open an issue at https://pagure.io/releng/

This package fails to install and maintainers are advised to take one of the following actions:

 - Fix this bug and close this bugzilla once the update makes it to the repository.
   (The same script that posted this comment will eventually close this bugzilla
   when the fixed package reaches the repository, so you don't have to worry about it.)

or

 - Move this bug to ASSIGNED if you plan on fixing this, but simply haven't done so yet.

or

 - Orphan the package if you no longer plan to maintain it.


If you do not take one of these actions, the process at https://docs.fedoraproject.org/en-US/fesco/Fails_to_build_from_source_Fails_to_install/#_package_removal_for_long_standing_ftbfs_and_fti_bugs will continue.
This package may be orphaned in 7+ weeks.
This is the first reminder (step 3) from the policy.

Don't hesitate to ask for help on https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/ if you are unsure how to fix this bug.


Note You need to log in before you can comment on or make changes to this bug.