from random import random from tornado import gen import motor import

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from random import random
from tornado import gen
import motor
import tornado
db = motor.MotorClient().test
@gen.coroutine
def example():
print('start')
db.messages.insert({'msg': random()})
db.messages.insert({'msg': random()})
db.messages.insert({'msg': random()})
cursor = db.messages.find()
while (yield cursor.fetch_next):
message = cursor.next_object()
print(message)
print('finish')
if __name__ == "__main__":
example()