Since I am using NDB for my projects, on Python 2.7 SDK, I cannot use
Query().iter() normally with Jinja2 templates.
My usual code follows this pattern:
mc_key = ...
instances = memcache.get('instances-%s' % mc_key)
if not instances:
q_i = MyModel.query(...)
instances = q_i.iter()
if instances:
memcache.set('instances-%s' % mc_key, instances)
And then in Jinja2:
{% for i in instances %}
{{i.property1}}
{% endfor %}
This also happens when I call the QueryIterator object in the Python code.
Adding to the previous Python code:
for i in instances:
pass # Do something with i
I always get a "deadlock waiting for <future created by XXX, pending>" when
I loop the iterator.
A working walkaround is:
q_i = MyModel.query()
instances = q_i.iter()
if instances:
instances = list(instances)
Someone knows why that next() does not work as I expected? Some more
elegant and/or efficient solution?
Thank you in advance.
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/d/optout.