Skip to content

Lock

Lock · Type

A lock taken by mash.lock(name, seconds). Held until release(), the end of the run (even when the run fails), or its seconds run out, whichever comes first. Only the run that took it can release it.

lock = mash.lock(“order:” + file.id, 120) if (!lock) { fail(“Another run is working on this order; try again in a minute”) } … lock.release()

NameTypeDescription
namestringThe name the lock was taken under.
lock.held() → bool

Whether this run still holds the lock (false after release() or once its seconds have run out).

lock.release() → bool

Release the lock now, so another run can take it. A script run by another (mash.scripts.run) that took a lock its caller holds shares the caller’s lock: its release() leaves it held for the caller.