Skip to main content

Module live_lock

Module live_lock 

Source
Expand description

Waiting for a lock a live process holds: a slow-wait notice naming the holder and a configurable backstop. What: Wait for a lock another live process holds, with a visible notice and a generous backstop. Why: A holder that is alive but stuck (a hung hook, a stalled tool) would otherwise stall every later command with no output at all. After a short silence the waiter says whom it waits for and when it will give up, and past the backstop it fails closed: the command stops with the holder named and the lock left in place.

In TS you’d write (pseudocode):

await acquireOwnerLock({ lockDirectory, signal: AbortSignal.timeout(limitMs), onSlow: announce });

Structs§

HolderNotice
What: A wait notice that prints one line to a sink once the wait is slow. Why: Brief contention stays silent, as the incumbent’s waits were; a long wait stops looking like a hang.

Constants§

DEFAULT_LIVE_WAIT
How long a command waits for a live holder when the variable is absent or unusable: longer than any ordinary hook run, short enough that a stuck holder is noticed within the hour.
LIVE_WAIT_VARIABLE
Environment variable that sets, in whole seconds, how long a command waits for a lock held by a live process.

Functions§

acquire_live_owner_lock
What: Take an owner lock, waiting for a live holder with a slow-wait notice on standard error, and giving up at this process’s wait limit. Why: One call replaces the silent unbounded wait at every lock a command may queue behind.
live_wait_limit
The wait limit this process runs under: the variable in its environment, or the default.
live_wait_limit_from
What: The wait limit for a value of the variable. Why: A missing, zero or malformed value falls back to the default, never to “no limit”.
slow_wait_line
What: The notice a slow wait prints. Why: It names the holder, the lock and both durations so the person can look at the holder or raise the limit.