Browse Source

Use motor.Op instead of gen.Task

INADA Naoki 11 years ago
parent
commit
5de384c9c1
1 changed files with 4 additions and 4 deletions
  1. 4 4
      tornado/server.py

+ 4 - 4
tornado/server.py

@@ -41,16 +41,16 @@ class QueryTestHandler(BaseHandler):
 
 
         if queries == 0:
         if queries == 0:
             random_id = random.randint(1, 10000)
             random_id = random.randint(1, 10000)
-            world = yield gen.Task(db.world.find_one,{"id": random_id}, fields={"_id": 0, "id": 1, "randomNumber": 1})
+            world = yield motor.Op(db.world.find_one,{"id": random_id}, fields={"_id": 0, "id": 1, "randomNumber": 1})
             # Get first postion on arguments, and so first postion in mongo return
             # Get first postion on arguments, and so first postion in mongo return
-            response = json.dumps(world[0][0])
+            response = json.dumps(world)
         else:
         else:
             worlds = []
             worlds = []
             for i in xrange(int(queries)):
             for i in xrange(int(queries)):
                 random_id = random.randint(1, 10000)
                 random_id = random.randint(1, 10000)
-                world = yield gen.Task(db.world.find_one,{"id": random_id}, fields={"_id": 0, "id": 1, "randomNumber": 1})
+                world = yield motor.Op(db.world.find_one,{"id": random_id}, fields={"_id": 0, "id": 1, "randomNumber": 1})
                 # Get first postion on arguments, and so first postion in mongo return
                 # Get first postion on arguments, and so first postion in mongo return
-                worlds.append(world[0][0])
+                worlds.append(world)
             response = json.dumps(worlds)
             response = json.dumps(worlds)
         self.set_header("Content-Type", "application/json; charset=UTF-8")
         self.set_header("Content-Type", "application/json; charset=UTF-8")
         self.finish(response)
         self.finish(response)