Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/viur/toolkit/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
Loading