def __iter__(self):
    """Create a generator for model instances for entities.

    Iterating through entities moves query range past the consumed entities.

    Yields:
      next model instance.
    """
    while True:
      query = self._key_range.make_ascending_query(
          util.for_name(self._entity_kind))
      results = query.fetch(limit=self._batch_size)

      if not results:
        break

      for model_instance in results:
        key = model_instance.key()

        self._key_range.advance(key)
        yield model_instance
Create a generator for model instances for entities.

    Iterating through entities moves query range past the consumed entities.

    Yields:
      next model instance.
    
mapreduce/input_readers.py