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()
Properties
Section titled “Properties”| Name | Type | Description |
|---|---|---|
name | string | The name the lock was taken under. |
Methods
Section titled “Methods”lock.held() → bool
Whether this run still holds the lock (false after release() or once its seconds have run out).
release
Section titled “release”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.