s365b.jobs.locks¶
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¶
The repository is locked by another job. |
Functions¶
|
Hold a repository's lock for the duration of the block. |
Module Contents¶
- exception s365b.jobs.locks.RepositoryBusyError[source]¶
Bases:
ExceptionThe repository is locked by another job.
- async s365b.jobs.locks.repository_lock(db: s365b.db.session.Database, repository_id: int, *, exclusive: bool, wait: bool = True) collections.abc.AsyncIterator[None][source]¶
Hold a repository’s lock for the duration of the block.
- Parameters:
db – Database.
repository_id – Repository row ID.
exclusive – Exclusive (retention) or shared (backups).
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
waitis False and the lock is taken.