A semaphore per store, made on first use.
Functions#
__init__#
__init__() -> Nonedef __init__(self) -> None:
self._semaphores: dict[StoreId, Semaphore] = {}__call__#
__call__(store_id) -> _WithLock| Parameter | Type | Description |
|---|---|---|
store_id | StoreId |
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)