teff.tool.builtin.lock¶
teff.tool.builtin.lock
¶
Distributed lock over a Redis-compatible store (Redis/KeyDB/Valkey).
A single lock tool with an action selector: acquire,
release, renew, status. A unique token is generated per tool
instance, so only the instance that acquired a lock can release or renew
it — release/renew are compare-and-{del,expire} Lua scripts, atomic on
the server, so a stale instance can never clobber a lock it does not own.
Useful in daemon workflows where several processes (or several ticks) must not review the same pull request at once.
Classes:
| Name | Description |
|---|---|
LockTool |
Distributed lock over Redis (KeyDB/Valkey supported). |
LockTool
¶
Bases: _RedisBase
Distributed lock over Redis (KeyDB/Valkey supported).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
|
required | |
key
|
Lock name. |
required | |
ttl
|
Lease length in seconds for |
required |
Args (config): same as the redis tool — url or
host/port/db/password/username.
Source code in teff/tool/builtin/lock.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |