I figured out what's wrong with my code so I did not bother to put in additional details.
Problem is, item has a _pre_put_hook()
that was querying another model, so the transaction fails.
Check your hooks if happen to encounter this error.
Question
Can anyone please point out what part of this is not allowed in a transactional function?
@ndb.transactional(propagation=ndb.TransactionOptions.INDEPENDENT)
def set_visibility(action, key):
item = key.get()
key = key.urlsafe()
if item:
key_name = action + '_' + key
cols = memcache.get(key_name)
if cols:
cols = cols.split(',')
for col in cols:
logging.info(key + '>>>>>>>' + col)
if action == 'unhide':
try:
item.uncollege.remove(col)
pass
except:
logging.error(col + ' already found in datastore blacklist of ' + item.banner_id)
else:
if col not in item.uncollege:
item.uncollege.append(col)
pass
else:
logging.error(col + ' already found in datastore blacklist of ' + item.banner_id)
item.put()
else:
logging.error('cant find memcache ' + key_name)
cols = memcache.set(key_name, '')
else:
logging.error('cant find entity ' + key)
Solution
I figured out what's wrong with my code so I did not bother to put in additional details.
Problem is, item has a _pre_put_hook()
that was querying another model, so the transaction fails.
Check your hooks if happen to encounter this error.