Expired queries and appengine

google-app-engine, python

Solution

This issue might shed some light on your problem: https://code.google.com/p/googleappengine/issues/detail?id=4432

Even though offline requests can currently live up to 10 minutes (and background instances can live forever) datastore queries can still only live for 30 seconds. We plan to improve this, but since a 'consistent' view of the data is only preserved for a limit period of time, there is an upper bound to how long a query can last (which is < 10 minutes).

...

Instead of running a single long query, consider fetching batches from the query using query cursors.

Problem

Within a task, I'm iterating over a collection of items with a query. After each entity is fetched from the query, I am also performing a URL request. After iterating over a large number of these items, I'm seeing the following error: ``` BadRequestError: The requested query has expired. Please restart it with the last cursor to read more results. ``` What is the lease on a query once you create it?

Original source