SemaphoreProtocol
SyncSemaphoreProtocol
SyncSemaphoreProtocol(
cache: CacheProtocol,
key: Any,
value: int = ...,
*,
timeout: float = ...,
expire: float | None = ...,
tags: str | Iterable[str] | None = ...
)
Bases: Protocol
Recipe for cross-process and cross-thread bounded semaphore.
Assumes the key will not be evicted. Set the eviction policy to 'none' on the cache to guarantee the key is not evicted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
CacheProtocol
|
Cache to use for semaphore. |
required |
|
Any
|
Key for semaphore. |
required |
|
int
|
Value for semaphore. |
...
|
|
float
|
Timeout for semaphore. |
...
|
|
float | None
|
Expiration time for semaphore. |
...
|
|
str | Iterable[str] | None
|
Tags for semaphore. |
...
|
Examples:
Source code in src/typed_diskcache/interface/sync.py
acquire
AsyncSemaphoreProtocol
AsyncSemaphoreProtocol(
cache: CacheProtocol,
key: Any,
value: int = ...,
*,
timeout: float = ...,
expire: float | None = ...,
tags: str | Iterable[str] | None = ...
)
Bases: Protocol
Recipe for cross-process and cross-thread bounded semaphore.
Assumes the key will not be evicted. Set the eviction policy to 'none' on the cache to guarantee the key is not evicted.
Asynchronous version of
SyncSemaphoreProtocol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
CacheProtocol
|
Cache to use for semaphore. |
required |
|
Any
|
Key for semaphore. |
required |
|
int
|
Value for semaphore. |
...
|
|
float
|
Timeout for semaphore. |
...
|
|
float | None
|
Expiration time for semaphore. |
...
|
|
str | Iterable[str] | None
|
Tags for semaphore. |
...
|
Examples: