grok2api / app /platform /storage /contract.py
FUCAT's picture
Deploy grok2api to HF Spaces (Docker)
7e55e53
Raw
History Blame Contribute Delete
601 Bytes
"""Abstract storage contract used by all persistence backends."""
from typing import Any, Protocol, runtime_checkable
@runtime_checkable
class LockHandle(Protocol):
"""Async context manager representing a distributed lock."""
async def __aenter__(self) -> "LockHandle": ...
async def __aexit__(self, *_: Any) -> None: ...
class StorageError(Exception):
"""Base class for all storage-layer errors."""
class LockAcquisitionError(StorageError):
"""Raised when a lock cannot be acquired within the timeout."""
__all__ = ["LockHandle", "StorageError", "LockAcquisitionError"]