sqlalchemy_dlock.asyncio.lock.postgresql module¶
- class sqlalchemy_dlock.asyncio.lock.postgresql.PostgresqlAsyncSadLock(connection_or_session: AsyncConnection | AsyncSession | async_scoped_session, key, **kwargs)[source]¶
Bases:
PostgresqlSadLockMixin,BaseAsyncSadLock[int]- Parameters:
key –
PostgreSQL advisory lock requires the key given by
INT64.When
keyisint, the constructor tries to ensure it to beINT64.OverflowErroris raised if too big or too small for that.When
keyisstrorbytesor alike, the constructor calculates its checksum byhashlib.blake2b(), and takes the hash result integer value as actual key.Or you can specify a
convertfunction to that argument:def convert(val: Any) -> int: int64_key: int = do_sth(val) return int64_key
shared –
sharedxact –
xactconvert – Custom function to covert
keyto required data type.connection_or_session (AsyncConnection | AsyncSession | async_scoped_session)