diff --git a/src/viur/toolkit/db.py b/src/viur/toolkit/db.py index 2b6d12f..c24b6d0 100644 --- a/src/viur/toolkit/db.py +++ b/src/viur/toolkit/db.py @@ -80,6 +80,12 @@ def set_status( If the function does not raise an Exception, all went well. It returns either the assigned skel, or the db.Entity on success. + + The read-check-write cycle always runs inside a datastore transaction: + if a transaction is already open, it joins it; otherwise a new one is + opened (with up to *retry* attempts on :exc:`db.ViurDatastoreError`). + This makes the precondition check and the write atomic -- concurrent + modifications of the same entity cannot be lost or interleaved. """ if key is None and skel is None: raise ValueError("No Key is provided") @@ -160,7 +166,7 @@ def transaction() -> skeleton.SkeletonInstance | db.Entity: return obj # In case of already in transaction, just call the function. - if db.IsInTransaction: + if db.IsInTransaction(): return transaction() # Otherwise, run the retry loop