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?
This issue might shed some light on your problem: https://code.google.com/p/googleappengine/issues/detail?id=4432
...
Simple create defered tasks for each element in your sequence. There is good article with examples how to do it right way "Background work with the deferred library".
I wrote a simple helper to do this - you call it with the batch_size, the object class for the query, and the callback that handles the elements in the query.
(Note, I am using djangoappengine and therefore django query format - but you could modify it to suit.)