sqlalchemy_dlock.asyncio.lock.postgresql module#
- class sqlalchemy_dlock.asyncio.lock.postgresql.PostgresqlAsyncSadLock(connection_or_session: TAsyncConnectionOrSession, key, **kwargs)#
Bases:
PostgresqlSadLockMixin
,BaseAsyncSadLock
- Parameters:
key –
PostgreSQL advisory lock requires the key given by
INT64
.When
key
isint
, the constructor tries to ensure it to beINT64
.OverflowError
is raised if too big or too small for that.When
key
isstr
orbytes
or alike, the constructor calculates its checksum byhashlib.blake2b()
, and takes the hash result integer value as actual key.Or you can specify a
convert
function to that argument:def convert(val: Any) -> int: int64_key: int = do_sth(val) return int64_key
shared –
shared
xact –
xact
convert – Custom function to covert
key
to required data type.connection_or_session (TAsyncConnectionOrSession) –
- async acquire(block: bool = True, timeout: float | int | None = None, interval: float | int | None = None) bool #
- async release()#