Lock
lock
One integration lock per git repository, shared by every AXM integrator.
Integrating an attempt (replaying its commits onto the lane, then
fast-forwarding the lane) and rolling an attempt back (removing its execution
worktree, re-verifying that none of its commits reached the lane) read and
write the same refs. Interleaved, a rollback can remove the worktree of an
attempt whose commits have just landed. Every such step therefore runs under
:func:repository_lock -- the warden and the tribunal dev.work.exec /
land graphs alike.
The lock is a protocol, not only this function: an advisory exclusive
flock(2) on :data:INTEGRATION_LOCK_NAME inside the repository's
common git directory (git rev-parse --git-common-dir), so every
worktree of one repository contends for the same file and distinct
repositories never contend. The kernel releases it when its holder exits, so
a crashed holder leaves no stale lock behind. Any process that integrates into
a lane must take it the same way, whatever its language.
RepositoryLockTimeoutError
repository_lock(repo_path, *, timeout)
Hold the integration lock of repo_path's repository for the block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_path
|
str | Path
|
Any directory inside the repository or one of its worktrees. |
required |
timeout
|
float
|
Seconds to wait for another holder to release the lock
( |
required |
Yields:
| Type | Description |
|---|---|
Path
|
The lock file's path. |
Raises:
| Type | Description |
|---|---|
ValueError
|
repo_path is not inside a git repository. |
RepositoryLockTimeoutError
|
another holder kept the lock past timeout. |
Source code in packages/axm-git/src/axm_git/core/lock.py
repository_lock_path(repo_path)
Return the lock file of the repository holding repo_path.
Every worktree of one repository resolves to the same path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_path
|
str | Path
|
Any directory inside a git repository or one of its worktrees. |
required |
Returns:
| Type | Description |
|---|---|
Path | None
|
|
Path | None
|
cannot place repo_path in a repository. |