Skip to content

Commit

Permalink
Complete the Motor example.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajdavis committed Jul 11, 2014
1 parent 1e33797 commit c7f21fa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/guide/coroutines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http://motor.readthedocs.org/en/stable/>`_::
from `Motor <http://motor.readthedocs.org/en/stable/>`_::

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()

0 comments on commit c7f21fa

Please sign in to comment.