Last active
December 30, 2015 11:19
-
-
Save yanmhlv/7821554 to your computer and use it in GitHub Desktop.
example for motor and tornado
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import motor | |
import tornado.gen as gen | |
@gen.coroutine | |
def foo1(): | |
conn = motor.MotorClient().open_sync() | |
db = conn['test'] | |
result = yield gen.Task(db.accounts.find().limit(10).to_list) | |
return result | |
@coroutine | |
def foo2(): | |
conn = motor.MongoClient().open_sync() | |
db = conn['test'] | |
result = yield motor.Op(db.users.find().sort([('_id', -1)]).limit(20).to_list) | |
return result | |
import tornado.ioloop | |
print foo1() | |
print foo2() | |
tornado.ioloop.IOLoop.instance().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment