Question

I've been reading the docs on transactions https://developers.google.com/appengine/docs/python/datastore/transactions, and this line sticks out

When a transaction fails, you can have your app retry the transaction until it succeeds, or you can let your users deal with the error by propagating it to your app's user interface level. You do not have to create a retry loop around every transaction.

Now I've created my transaction using @db.transactional but I don't know how to explicitly retry it. I'm guessing that another transaction is updating the entity and the second call to the transaction is giving up (could be wrong about that).

How do I retry my transaction?

self.my_txn(key,0)   

@db.transactional()
def my_txn(self,key,value):
   ent = db.get(key)
   ent.value = value
Was it helpful?

Solution

You can specify a retries parameter to the decorator:

@db.transactional(retries=5)
def my_txn...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top