docs
docs copied to clipboard
Mention `asyncio` option in `set_loop_type` docs
https://www.rethinkdb.com/api/python/set_loop_type/ is missing the "asyncio"
option.
It's also missing from http://rethinkdb.com/docs/async-connections/#python-with-tornado-or-twisted . Pinging @Tryneus for example code.
Hey @Tryneus, I'd love to help with the documentation.
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.
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.
+1 on the document update. Was looking for asyncio examples and was confused to only find Tornado/Twisted ones available.
:+1: please, some example for us n00bs would be greatly appreciated too :)
+1
This is related to and dependent on rethinkdb/rethinkdb#5354
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.
+1