GitHub

StoreLocks

API reference for StoreLocks.

A semaphore per store, made on first use.

Functions

__init__

__init__() -> None
def __init__(self) -> None:
    self._semaphores: dict[StoreId, Semaphore] = {}

__call__

__call__(store_id) -> _WithLock
ParameterTypeDescription
store_idStoreId

Returns _WithLock

def __call__(self, store_id: StoreId) -> _WithLock:
    semaphore = self._semaphores.get(store_id)
    if semaphore is None:
        semaphore = self._semaphores[store_id] = Semaphore(1)
    return _WithLock(semaphore)