sqlalchemy_dlock.factory module¶
- sqlalchemy_dlock.factory.create_async_sadlock(connection_or_session, key, /, contextual_timeout=None, **kwargs)[source]¶
AsyncIO version of
create_sadlock()- Return type:
BaseAsyncSadLock[TypeVar(KTV),TypeVar(AsyncConnectionTV, bound=Union[AsyncConnection,AsyncSession,async_scoped_session])]- Parameters:
- sqlalchemy_dlock.factory.create_sadlock(connection_or_session, key, /, contextual_timeout=None, **kwargs)[source]¶
Create a database distributed lock object
All arguments will be passed to a sub-class of
BaseSadLock, depend on the type ofconnection_session’s SQLAlchemy engine.- Parameters:
connection_or_session (
TypeVar(ConnectionTV, bound=Union[Connection,Session,scoped_session])) – Connection or Session object SQL locking functions will be invoked on it.key (
TypeVar(KTV)) – ID or name of the SQL locking functioncontextual_timeout (
Union[float,int,None]) –Timeout(seconds) for Context Managers.
When called in a
withstatement, the new created lock object will pass it totimeoutargument ofBaseSadLock.acquire().A
TimeoutErrorwill be thrown if can not acquire aftercontextual_timeout
- Return type:
BaseSadLock[TypeVar(KTV),TypeVar(ConnectionTV, bound=Union[Connection,Session,scoped_session])]- Returns:
New created lock object
Type of the lock object is a sub-class of
BaseSadLock, which depends on the passed-in SQLAlchemy connection or session.MySQL and PostgreSQL connection/session are supported til now.