문제

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
도움이 되었습니까?

해결책

You can specify a retries parameter to the decorator:

@db.transactional(retries=5)
def my_txn...
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top