Fetching the results of async queries

14 views
Skip to first unread message

gwstuff

unread,
Nov 20, 2011, 2:54:15 AM11/20/11
to google-a...@googlegroups.com
Hi,

I would like to run a set of datastore queries asynchronously so that they execute in parallel. Unfortunately, the synchronous and async versions of my code produce different results. It seems that the async version does not finish by the time I actually need the results. At that point, I need to call 'get_results' but am unsure how to since this is not documented.

Here are the two fragments of code:

Sync (works)

                note_iter = n.children.fetch(MAX_NOTES)
                ...
                for n in note_iter:
                    consume(n)

ASync (fewer results)
  
                note_iter = n.children.run()
                ...
                for n in note_iter:
                    consume(n)

Any insight or pointers would be much appreciated.

Amy Unruh

unread,
Nov 21, 2011, 1:45:29 AM11/21/11
to google-a...@googlegroups.com
hi,

Query.run() only pre-fetches asynchronously as time allows; when you access the iterator it fetches results as needed.
You should not see fewer results using run()-- and I was not able to reproduce your issue with a test app.
You might double check that your queries are the same in both cases.

 -Amy


--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/NosdvNHbvyEJ.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.

Reply all
Reply to author
Forward
0 new messages