count = 0
query = cls.all().order('__key__')
while count % 1000 == 0:
    current_count = query.count()
if current_count == 0:
    break
count += current_count
if current_count == 1000:
    last_key = query.fetch(1, 999)[0].key()
query = query.filter('__key__ > ', last_key)
return count
How to fetch more than 1000?