Skip to content

Latest commit

 

History

History
54 lines (43 loc) · 1.79 KB

set_loop_type.md

File metadata and controls

54 lines (43 loc) · 1.79 KB
layout api-command
language Python
permalink api/python/set_loop_type/
command set_loop_type
javascript false
rb false
js false
java false
related_commands
connect run
connect/
run/

Command syntax

{% apibody %} r.set_loop_type(string) {% endapibody %}

Description

Set an asynchronous event loop model. There are two supported models:

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.