From c7f21fae00e0d95433acd7701129a3e2db0db83a Mon Sep 17 00:00:00 2001 From: "A. Jesse Jiryu Davis" Date: Fri, 11 Jul 2014 13:03:16 -0400 Subject: [PATCH] Complete the Motor example. --- docs/guide/coroutines.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/guide/coroutines.rst b/docs/guide/coroutines.rst index bc400833c..f10dda302 100644 --- a/docs/guide/coroutines.rst +++ b/docs/guide/coroutines.rst @@ -132,11 +132,13 @@ Looping is tricky with coroutines since there is no way in Python to ``yield`` on every iteration of a ``for`` or ``while`` loop and capture the result of the yield. Instead, you'll need to separate the loop condition from accessing the results, as in this example -from `motor `_:: +from `Motor `_:: import motor + db = motor.MotorClient().test + @gen.coroutine def loop_example(collection): - cursor = collection.find() + cursor = db.collection.find() while (yield cursor.fetch_next): doc = cursor.next_object() -- 2.47.2