Semaphore locks for pi to coordinate multiple pi instances.
pi install git:github.com/offline-ant/pi-semaphoreOr try without installing:
pi -e git:github.com/offline-ant/pi-semaphoreWhile the agent is processing, a lock file exists at:
/tmp/pi-semaphores/<name>
Default <name>:
PI_LOCK_NAME(if set)- Otherwise, project directory basename
If the same name is already taken, a suffix is appended (-2, -3, ...).
When processing finishes, the lock is removed and an idle marker is created:
/tmp/pi-semaphores/idle:<name>
With tmux integration, lock file content is the pane id (for example %42), so other tools can resolve lock name -> pane.
| Variable | Description |
|---|---|
PI_LOCK_NAME |
Override the default lock name |
| Command | Description |
|---|---|
/lock [name] |
Create a named lock (auto-deduplicates) |
/release [name] |
Release a named lock |
/wait <name> [name...] |
Wait for any named lock to be released |
/lock-list |
List all lock files in /tmp/pi-semaphores/ |
Terminal 1:
> Do long task
Terminal 2:
> /wait my-project
Waiting for any lock: my-project
# ... blocks ...
Lock released: my-project
Use with pi-tmux:
- Wait for worker step completion via
semaphore_wait - Capture worker pane by lock name via
tmux-capture - Send next instruction via
tmux-send
Because lock files contain pane ids, supervisors can control worker panes by lock name without spawning them.
MIT