def with_locks

cswap-bend-cli@0.1.0.0 · swlive.bend:219

import cswap-bend-cli@0.1.0.0/swlive.bend as Swlive
import Base
import cswap-bend-cli@0.1.0.0/act.bend as Act
import cswap-bend-cli@0.1.0.0/lock.bend as Lock
import cswap-bend-cli@0.1.0.0/dirlock.bend as Dirlock
import cswap-bend-cli@0.1.0.0/store/base.bend as SBase

219# Claude Code's lock directories and cswap's own flock, in the reference's
220# order: .lock, then the credentials pair, then the config lock.
221def with_locks(-A: Type, +ctx: SBase.Ctx, act: Act.of(A)) -> Act.of(A):
222  Lock.with_lock(A, SBase.lock_path(SBase.root_of(ctx)), 10000,
223    Dirlock.with_dirlock(A, config_home_of(ctx) ++ "/.oauth_refresh.lock", 9000, 60,
224      Dirlock.with_dirlock(A, config_home_of(ctx) ++ ".lock", 9000, 60,
225        Dirlock.with_dirlock(A, SBase.global_config_path(ctx) ++ ".lock", 9000, 10, act))))

Uses (9)

Used by (1)