From: A. Jesse Jiryu Davis Date: Fri, 11 Jul 2014 17:03:16 +0000 (-0400) Subject: Complete the Motor example. X-Git-Tag: v4.0.0~11^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c7f21fae00e0d95433acd7701129a3e2db0db83a;p=thirdparty%2Ftornado.git Complete the Motor example. --- 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()