set_loop_type
ReQL command: set_loop_type
Command syntax
r.set_loop_type(string)
Description
Set an asynchronous event loop model. There are two supported models:
-
"tornado"
: use the Tornado web framework. Under this model, the connect and run commands will return TornadoFuture
objects. -
"twisted"
: use the Twisted networking engine. Under this model, the connect and run commands will return TwistedDeferred
objects. -
"gevent"
: use the gevent networking library. (Unlike the other asynchronous models, this does not change connect and run handling; inside the event loop, this is indistinguishable from the default Python driver.) -
"asyncio"
: use Python 3’s asyncio package. Under this model, the connect and run commands will return asyncioFuture
objects.
Example: Read a table’s data using Tornado.
r.set_loop_type("tornado") conn = r.connect(host='localhost', port=28015) @gen.coroutine def use_cursor(conn): # Print every row in the table. cursor = yield r.table('test').order_by(index="id").run(yield conn) while (yield cursor.fetch_next()): item = yield cursor.next() print(item)
For a longer discussion with both Tornado and Twisted examples, see the documentation article on Asynchronous connections.
Related commands
Get more help
Couldn't find what you were looking for?
- Ask a question on Stack Overflow
- Chat with us and our community on Slack
- Talk to the team on IRC on #rethinkdb@freenode.net — via Webchat
- Ping @rethinkdb on Twitter
- Post an issue on the documentation issue tracker on GitHub
© RethinkDB contributors
Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
https://rethinkdb.com/api/python/set_loop_type/