Skip to content

asyncio deprecated '@asyncio.coroutine' in python 3.11 #294

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

Closed
dasunprem opened this issue Oct 4, 2023 · 3 comments
Closed

asyncio deprecated '@asyncio.coroutine' in python 3.11 #294

dasunprem opened this issue Oct 4, 2023 · 3 comments
Labels
bug Something isn't working not qualified The issue is not checked yet by the owners

Comments

@dasunprem
Copy link

dasunprem commented Oct 4, 2023

Hi,
I have installed the RethinkDB python driver using pip install rethinkdb and its working perfectly well.
But when I connecting with asyncio using r.set_loop_type('asyncio'), it throws an error module 'asyncio' has no attribute 'coroutine'.
My python version is 3.11

To Reproduce
Steps to reproduce the behavior:
I installed with pip install rethinkdb and the installed version in 2.4.9

System info

  • OS: [OpenSUSE Tumbleweed]
  • RethinkDB Version: [e.g. 2.4.9]

Additional context
As a personal experiment I remove all the @asyncio.coroutine and added async in front of the reletive def and replaced yeild from to await on the file rethinkdb/asyncio_net/net_asyncio.py

As the coroutine bug is possibly fixed by the above changes I get a new error as follows

  File "/home/phenom-02/.local/share/virtualenvs/PhenomAuth2-s29yQfHp/lib/python3.11/site-packages/rethinkdb/ast.py", line 154, in run
    return c._start(self, **global_optargs)
           ^^^^^^^^
AttributeError: 'coroutine' object has no attribute '_start'```
@dasunprem dasunprem added bug Something isn't working not qualified The issue is not checked yet by the owners labels Oct 4, 2023
@srh
Copy link
Contributor

srh commented Oct 4, 2023

The cause is that generator-based coroutines with @asyncio.coroutine have been removed in 3.11.

https://docs.python.org/3.10/library/asyncio-task.html#generator-based-coroutines

async def was added in Python 3.5. It looks like Ubuntu 16.04 even has Python 3.5, so I think we don't really need to worry about compatibility.

https://launchpad.net/ubuntu/xenial/+package/python3

@srh
Copy link
Contributor

srh commented Oct 4, 2023

As the coroutine bug is possibly fixed by the above changes I get a new error as follows

Could that be a bug in your own code? _start is supposed to be called on a connection, so maybe you need an await in your code. (I'm not familiar with Python async at all, so I'm shooting in the dark.)

@srh
Copy link
Contributor

srh commented Oct 10, 2023

This is fixed by #298. Currently Python 3.11 is known to work on the master branch with respect to this issue. Follow #301 for a versioned release.

@srh srh closed this as completed Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working not qualified The issue is not checked yet by the owners
Projects
None yet
Development

No branches or pull requests

2 participants