rethinkdb / rethinkdb-python

Python driver for RethinkDB
https://rethinkdb.com/api/python/
Apache License 2.0
64 stars 35 forks source link

Asyncio not compatible with python 3.10 #264

Closed luckydonald closed 10 months ago

luckydonald commented 2 years ago

Describe the bug The most basic example fails BaseEventLoop.create_connection() got an unexpected keyword argument 'loop'

To Reproduce Steps to reproduce the behavior:

Expected behavior It works.

Screenshots

 Traceback (most recent call last):
           File "/Users/luckydonald/.pyenv/versions/3.10.0/lib/python3.10/site-packages/rethinkdb/asyncio_net/net_asyncio.py", line 202, in connect
             self._streamreader, self._streamwriter = yield from asyncio.open_connection(
           File "/Users/luckydonald/.pyenv/versions/3.10.0/lib/python3.10/asyncio/streams.py", line 47, in open_connection
             transport, _ = await loop.create_connection(
         TypeError: BaseEventLoop.create_connection() got an unexpected keyword argument 'loop'

System info

luckydonald commented 2 years ago

But it's apparently not only the loop parameter:

stephanelsmith commented 2 years ago

Bump, running into this now.

Also... asyncio_net/net_asyncio.py, asyncio.get_event_loop is being deprecated as well. Should be using asyncio.get_running_loop per https://docs.python.org/3/library/asyncio-eventloop.html

antony66 commented 11 months ago

Umm. Not sure if the library is still alive. But in any case, here's what I get when trying to use it with asyncio on python 3.11:

In [1]: from rethinkdb import r

In [2]: r.set_loop_type('asyncio')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[2], line 1
----> 1 r.set_loop_type('asyncio')

File ~/miniforge3/envs/py311/lib/python3.11/site-packages/rethinkdb/__init__.py:65, in RethinkDB.set_loop_type(self, library)
     63 def set_loop_type(self, library=None):
     64     if library == "asyncio":
---> 65         from rethinkdb.asyncio_net import net_asyncio
     66         self.connection_type = net_asyncio.Connection
     68     if library == "gevent":

File ~/miniforge3/envs/py311/lib/python3.11/site-packages/rethinkdb/asyncio_net/net_asyncio.py:42
     38 pResponse = ql2_pb2.Response.ResponseType
     39 pQuery = ql2_pb2.Query.QueryType
---> 42 @asyncio.coroutine
     43 def _read_until(streamreader, delimiter):
     44     """Naive implementation of reading until a delimiter"""
     45     buffer = bytearray()

AttributeError: module 'asyncio' has no attribute 'coroutine'
srh commented 11 months ago

We now have #294 for the Python 3.11 issue.

But there are a bunch of other PRs open that might carry the change -- I guess they should be looked at first.

lsabi commented 11 months ago

@antony66 the library is still alive....kinda. We're quite busy and find little time to work on the project that has been abandoned for a long time. Furthermore, the changes in the python ecosystem are happening quite fast.

We're working on supporting python 3.10+ and drop support for python 2.XX . See the branch https://github.com/rethinkdb/rethinkdb-python/tree/lsabi/commands

To a basic implementation (asyncio only) we're lacking the last checks here and there on the commands. The rest should be working. If you have knowledge and time enough, feel free to contribute on this branch

srh commented 11 months ago

asyncio_net/net_asyncio.py, asyncio.get_event_loop is being deprecated as well. Should be using asyncio.get_running_loop per

Thanks for the info. Since get_running_loop is new in Python 3.7 and get_event_loop is not broken yet, I'm going to not update that just yet. (I'm trying to make the minimal set of PR's to get 3.10 and 3.11 more working right now.)

antony66 commented 11 months ago

@lsabi let’s see if I can help

fdemian commented 10 months ago

@lsabi I'm having this very issue. I would like to use this driver with python3.11 and onwards.

Is there anythingI can help with? Maybe implement some of the changes suggested in the PR.

srh commented 10 months ago

@fdemian This is now already fixed in the master branch and you could build and use the driver off that yourself. I also created #301 to nag the devs into cutting a new release with these fixes.

lsabi commented 10 months ago

Closing as this has now been fixed with the latest release https://github.com/rethinkdb/rethinkdb-python/releases/tag/v2.4.10