Hi all!

The following snippet raises IndexError: pop from empty list. Since it gets 
executed in a task queue, the google app engine retries as ususal and then 
succeeds with same incoming data set. But it's a annoyance. The incoming 
data to_create is a standard python list.

@ndb.tasklet def create_new_stuff(to_create): if not to_create: raise 
ndb.Return([]) first, last = yield 
Translator.allocate_ids_async(len(to_create)) translator_ids = range(first, 
last + 1) # we from time to time get an IndexError on the 
translator_ids.pop(), huh? assert len(translator_ids) == len(to_create), 
(first, last, len(to_create)) logger.debug("Preallocated Translators: %s 
==? %s" % ( len(translator_ids), len(to_create))) @ndb.tasklet def 
create_stuff_transactional(item): @ndb.tasklet def txn(): try: 
translator_key = ndb.Key(Translator, translator_ids.pop()) except 
IndexError: logger.debug('Now: %s' % len(to_create)) raise ... raise 
ndb.Return(...new_entity...) new_entity = yield ndb.transaction_async(txn, 
xg=True) raise ndb.Return(new_entity) tasks = yield 
[create_stuff_transactional(item) for item in to_create] raise 
ndb.Return(tasks)

If it fails, the above code logs 

   1. 
   
   Preallocated Translators: 3 ==? 3
   
   2. 
   
   Now: 3
   
   

WTF?
It may be I just looked too often at this fragment, but the hell I don't 
get it.

Any ideas?

Regards



-- 
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/-/AYqe4-xeswcJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to