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.StateABCfor use by workers.Produces log messages on the
momotor.rpc.sharedlogger.- 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 when exclusive is
False(read mode), butOnly one process can hold the lock when exclusive is
True(write mode). No other processes can hold the lock while one process has it locked exclusively.
- Parameters:
- Return type:
- Returns:
- Raises:
- async test_lock(key, *, exclusive=True)¶
Test the lock. Returns
Trueif the lock is currently not being held.Not that this is very transient information. The lock could be acquired immediately after this method returns.