fix(issue-50): review findings of PR #56 on macOS
- admission: a `submit --dry-run` record is marked dry_run and is not an open job of its session (review 1e25cf2f F1) - create: the monitor-row adoption requires the row's server to be the one this create spawned on (review 1e25cf2f F2) - pane lock: retry only on contention (BlockingIOError); the docs say the flock lasts while any fd-9 holder (the claim shell and the shim) lives (review 66680d9d) - tests on macOS: real-herdr box HOMEs under /tmp (sun_path is 104 bytes), resolved paths, the fake claude reads non-canonical input (MAX_CANON 1024) and the pane is read unwrapped; lock holders exec their sleep so killing them frees the lock; the adoption tests name the server Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VCgu9Fa9iT7TbJUSzdq4Ff
This commit is contained in:
1 parent
320aa9f7a0
commit
a9ffedac36
10 files changed
+75
-19
No files matched your search
@@ -19,9 +19,12 @@ one lock per server from the choice to the claim.
|
||||
`locked`, or `timeout` once MAM_PANE_CLAIM_WAIT_S
|
||||
(default 120, minimum 1) has passed
|
||||
|
||||
The lock is a BSD flock, which belongs to the open file the shim holds on fd 9:
|
||||
it outlives this helper and ends with the shim's process, however that ends
|
||||
(exit, kill -9), so a dead holder leaves nothing to steal. flock(1) is not on
|
||||
The lock is a BSD flock, which belongs to the open file on fd 9: it outlives
|
||||
this helper and ends when the last process holding that fd ends, however it
|
||||
ends (exit, kill -9), so a dead holder leaves nothing to steal. The holders are
|
||||
the shell running the claim block and the command it runs (the shim); a child
|
||||
that outlived them would keep it too, so nothing long-lived may inherit fd 9 -
|
||||
the herdr server is spawned with close_fds (review 66680d9d). flock(1) is not on
|
||||
macOS; fcntl.flock is. Stdlib only, Python 3.9.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
@@ -67,13 +70,14 @@ def wait_s(env: Mapping[str, str]) -> int:
|
||||
def acquire(fd: int, wait: float) -> str:
|
||||
"""`locked`, or `timeout` when the lock was not free within `wait` s. The
|
||||
deadline is on the monotonic clock; a step of the wall clock does not
|
||||
stretch or cut it."""
|
||||
stretch or cut it. Only contention is waited out: any other error (a bad
|
||||
fd) raises, which the shim reports as an undecided lock."""
|
||||
deadline = time.monotonic() + wait
|
||||
while True:
|
||||
try:
|
||||
fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
return "locked"
|
||||
except OSError:
|
||||
except BlockingIOError:
|
||||
if time.monotonic() >= deadline:
|
||||
return "timeout"
|
||||
time.sleep(0.2)
|
||||
|
||||
Reference in new issue
Block a user