timeouts even after chunking datastore calls

1 view
Skip to first unread message

ken keller

unread,
May 20, 2009, 12:54:26 PM5/20/09
to Google App Engine
def clearDatastore(request):
ti = time.clock()
all = Thing.all()
for x in all:
x.delete()
if time.clock() - ti >= 8:
return HttpResponseRedirect("/clearDatastore")

Any ideas on why the above times out? Thx.

Jeff S (Google)

unread,
May 20, 2009, 3:02:17 PM5/20/09
to Google App Engine
Hi notcourage,

The following lines attempt to iterate through all of the entities in
a kind and deletes them one at a time.



all = Thing.all()
for x in all:
...

Since you check the time to do a redirect, it looks like this should
avoid the 30 second time limit. Do you know what kind of timeout error
you are seeing (datastore vs request deadline)?

One thing that might help is fetching a small number of entities per
request and deleting just a few at a time. It might look something
like:

db.delete(Thing.all().fetch(10))

Note, you don't need to iterate over the results of the all query as
delete will take a list of entities.

Happy coding,

Jeff
Reply all
Reply to author
Forward
0 new messages