docs icon indicating copy to clipboard operation
docs copied to clipboard

Mention `asyncio` option in `set_loop_type` docs

Open danielmewes opened this issue 8 years ago • 10 comments

https://www.rethinkdb.com/api/python/set_loop_type/ is missing the "asyncio" option.

danielmewes avatar Nov 13 '15 00:11 danielmewes

It's also missing from http://rethinkdb.com/docs/async-connections/#python-with-tornado-or-twisted . Pinging @Tryneus for example code.

danielmewes avatar Nov 16 '15 18:11 danielmewes

Hey @Tryneus, I'd love to help with the documentation.

gamesbrainiac avatar Nov 16 '15 18:11 gamesbrainiac

Building a demo with this and just found the lack of asyncio documentation for Python. :+1:

What's the correct pattern with await and a changefeed @Tryneus? I'm getting this error currently with this code:

conn = await r.connect("localhost", 28015)
changes = await db.changes().run(conn)
for change in changes:
    # do stuff with change

Error:

future: <Task finished coro=<send_message_to_slack() done, defined at async_slacker_rethinkdb.py:81> exception=TypeError("'AsyncioCursor' object is not iterable",)>
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "async_slacker_rethinkdb.py", line 88, in send_message_to_slack
    for change in changes:
TypeError: 'AsyncioCursor' object is not iterable
02-03 11:40:24 asyncio      ERROR    Task exception was never retrieved
future: <Task finished coro=<giphy_translate() done, defined at async_slacker_rethinkdb.py:45> exception=TypeError("'AsyncioCursor' object is not iterable",)>
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "async_slacker_rethinkdb.py", line 51, in giphy_translate
    for change in changes:
TypeError: 'AsyncioCursor' object is not iterable

Is it not possible for AsyncioCursor to also support __iter__ and or .next()?

Edit Ahh I see .next being inherited from Cursor.

dalanmiller avatar Feb 03 '16 19:02 dalanmiller

This also needs to be mentioned in the 'Asynchronous connections' article: https://www.rethinkdb.com/docs/async-connections/

There are only Twisted / Tornado examples there.

mglukhovsky avatar Apr 17 '16 14:04 mglukhovsky

+1 on the document update. Was looking for asyncio examples and was confused to only find Tornado/Twisted ones available.

davidchua avatar Apr 17 '16 14:04 davidchua

:+1: please, some example for us n00bs would be greatly appreciated too :)

ultrabug avatar May 30 '16 16:05 ultrabug

+1

wwoods avatar Jun 16 '16 15:06 wwoods

This is related to and dependent on rethinkdb/rethinkdb#5354

dalanmiller avatar Jun 16 '16 17:06 dalanmiller

Is there any way to get back to default loop_type after switching to asyncio? Part of my code is written in python 2.7, doesn't support async functions and it fails to run when Future object is received. What I mean is something like r.set_loop_type() to reset default settings.

desprit avatar Mar 15 '18 20:03 desprit

+1

kthblmfld avatar Nov 21 '18 00:11 kthblmfld