s365b.jobs.locks ================ .. py:module:: s365b.jobs.locks .. autoapi-nested-parse:: Per-repository locks shared between processes (Postgres advisory locks). Backups hold a repository's lock *shared*: any number may write at once. Retention's space reclamation holds it *exclusively*, because it deletes blobs nothing refers to, and a running backup could be about to reuse one of them (de-duplication). Exceptions ---------- .. autoapisummary:: s365b.jobs.locks.RepositoryBusyError Functions --------- .. autoapisummary:: s365b.jobs.locks.repository_lock Module Contents --------------- .. py:exception:: RepositoryBusyError Bases: :py:obj:`Exception` The repository is locked by another job. .. py:function:: repository_lock(db: s365b.db.session.Database, repository_id: int, *, exclusive: bool, wait: bool = True) -> collections.abc.AsyncIterator[None] :async: Hold a repository's lock for the duration of the block. :param db: Database. :param repository_id: Repository row ID. :param exclusive: Exclusive (retention) or shared (backups). :param wait: Wait for the lock; if False, raise when it is taken. :Yields: Nothing; the lock is held until the block ends. :raises RepositoryBusyError: If ``wait`` is False and the lock is taken.