Summary
Python 3.11.0 was officially released on Oct 24, 2022.
While trying to upgrade our python environments to python 3.11, we've encountered an ImportError in the motor.motor_asyncio module:
>>> import motor.motor_asyncio Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.11/dist-packages/motor/motor_asyncio.py", line 18, in <module> from .frameworks import asyncio as asyncio_framework File "/usr/local/lib/python3.11/dist-packages/motor/frameworks/asyncio/__init__.py", line 26, in <module> from asyncio import coroutine # For framework interface. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ImportError: cannot import name 'coroutine' from 'asyncio' (/usr/lib/python3.11/asyncio/__init__.py)
{}We've tried updating to motor 3.0.0 and even to 3.1.0.dev0, to no success.
The line in question slightly changed in form (while also introducing some deprecation warnings for motor dependencies as it seems), but the core issue is still present:
>>> import motor.motor_asyncio /usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.12) or chardet (3.0.4) doesn't match a supported version! warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported " Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.11/dist-packages/motor/motor_asyncio.py", line 18, in <module> from .frameworks import asyncio as asyncio_framework File "/usr/local/lib/python3.11/dist-packages/motor/frameworks/asyncio/__init__.py", line 27, in <module> from asyncio import coroutine, get_event_loop # noqa: F401 - For framework interface. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ImportError: cannot import name 'coroutine' from 'asyncio' (/usr/lib/python3.11/asyncio/__init__.py)
I feel that this should be considered a bug since motor documentation doesn't explicitly state that Python 3.11 is not (yet) supported. From the looks of it, the issue might be resolved with some house-cleaning.
Motivation
Who is the affected end user?
All motor users upgrading to Python 3.11.
How does this affect the end user?
This issue is a blocker.
How likely is it that this problem or use case will occur?
Very likely, since Python 3.11 offers tangible performance boost over previous versions and a couple of useful language features.
If the problem does occur, what are the consequences and how severe are they?
Most likely it will cause a number of forks with hotfixes in the meantime, optimistically - a pull request to fix the issue.
Is this issue urgent?
Not yet.
Is this ticket required by a downstream team?
No.
Is this ticket only for tests?
No.
- backports
-
MOTOR-1102 motor raises Runtime Error : Event loop is closed
- Closed