INNER CODE UNIT · Python
run_in_transaction
ArcadeData/arcadedb · bindings/python/src/arcadedb_embedded/core.py:130
def run_in_transaction(self, fn, retries: int = 12, backoff_s: float = 0.005):
"""
Execute a callable inside a transaction with automatic retry on
concurrent-modification conflicts.
Mirrors the Java API's ``database.transaction(lambda)`` semantics: on
``ConcurrentModificationException`` / ``NeedRetryException`` the
transaction is rolled back and ``fn`` is re-executed, with linear
backoff. The ``with db.transaction():`` context manager cannot retry
(a ``with`` block can't be re-entered), so use this for contended
multi-threaded writes.
Args:
fn: Zero-argument callable executed inside the transaction.
retries: Max retry attempts on conflict (default 12).
backoff_s: Base sleep between attempts, grows linearly.
Returns: