asyncio & RethinkDB changefeeds example
import rethinkdb as r | |
import asyncio | |
r.set_loop_type("asyncio") | |
async def get_connection(): | |
return await r.connect("localhost", 28015) | |
async def changefeed_old(): | |
conn = await get_connection() | |
changes = await r.db("test").table("test").changes()["new_val"].run(conn) | |
async for change in changes: | |
print(change) | |
async def changefeed_new(): | |
conn = await get_connection() | |
changes = await r.db("test").table("test").changes()["old_val"].run(conn) | |
async for change in changes: | |
print(change) | |
loop = asyncio.get_event_loop() | |
loop.create_task(changefeed_old()) | |
loop.create_task(changefeed_new()) | |
loop.run_forever() |
This comment has been minimized.
This comment has been minimized.
Same error with 3.6. Is there a way to fix it ? What am I doing wrong ? |
This comment has been minimized.
This comment has been minimized.
After reviewing a lot of amazing work by David Beazley (https://github.com/dabeaz), and with the improvements in async python (mainly introduction of I have created a gist here with a working example It gives a simple structure to listen to multiple change feeds asynchronously (tested on python 3.6) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
I am running the code in python 3.6 and it says
'async for' requires an object with aiter method, got AsyncioCursor