Shared state¶
The momotor.rpc.shared
module contains wrapper classes to use the shared state services
- class momotor.rpc.shared.SharedState(stub)¶
An implementation of
momotor.shared.state.StateABC
for use by workers.Produces log messages on the
momotor.rpc.shared
logger.- Parameters
stub (
WorkerStub
) – The connected worker stub
- get_lock(key, *, exclusive=True)¶
Context manager to get a lock. The lock is held while the context is active.
The lock is an ‘exclusive’ or ‘read/write’ lock:
Many processes can hold the lock with
exclusive
==False
(read mode), butOnly one process can hold the lock with
exclusive
==True
(write mode). No other processes can hold the lock while one process has it locked exclusively.
- Parameters
- Return type
AbstractAsyncContextManager
[None
]- Returns
- Raises
- async test_lock(key, *, exclusive=True)¶
Test the lock. Returns
True
if the lock is currently not being held.Not that this is very transient information. The lock could be acquired immediately after this method returns.