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 is int, the constructor tries to ensure it to be INT64. OverflowError is raised if too big or too small for that.

    • When key is str or bytes or alike, the constructor calculates its checksum by hashlib.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
      

  • sharedshared

  • xactxact

  • 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#
Parameters:
Return type:

bool

async release()#