pip_services3_components.lock.MemoryLock module
-
class
pip_services3_components.lock.MemoryLock.
MemoryLock
Bases:
pip_services3_components.lock.Lock.Lock
Lock that is used to synchronize execution within one process using shared memory.
Remember: This implementation is not suitable for synchronization of distributed processes.
- ### Configuration parameters ###
- options:
retry_timeout: timeout in milliseconds to retry lock acquisition. (Default: 100)
Example:
lock = MemoryLock() lock.acquire_lock("123", "key1", None, None) # processing lock.release_lock("123", "key1")
-
release_lock
(correlation_id: Optional[str], key: str) Releases the lock with the given key.
- Parameters
correlation_id – not user.
key – the key of the lock that is to be released.
-
try_acquire_lock
(correlation_id: Optional[str], key: str, ttl: int) Makes a single attempt to acquire a lock by its key.
It returns immediately a positive or negative result.
- Parameters
correlation_id – (optional) transaction id to trace execution through call chain.
key – a unique lock key to acquire.
ttl – a lock timeout (time to live) in milliseconds.
- Returns
receives a lock result.