Skip to content

Concurrency

rn_forge.sqlalchemy.concurrency

Optimistic concurrency over a :class:~rn_forge.sqlalchemy.VersionMixin row.

update_versioned(session, obj, **values) async

Update obj's row only if its version is still the one obj holds.

Issues UPDATE … WHERE pk = :pk AND version = :expected with version = expected + 1, then refreshes obj. Does not commit.

Parameters:

Name Type Description Default
session AsyncSession

The session obj belongs to.

required
obj T

A persistent instance of a model using VersionMixin.

required
**values Any

Column values to set.

{}

Returns:

Type Description
T

obj, refreshed.

Raises:

Type Description
VersionConflict

The row exists at a different version (412).

LookupError

The row no longer exists.