Package entropy :: Module locks :: Class SimpleFileLock

Class SimpleFileLock

source code


Helper class that makes it easy to acquire and release file based locks.

Instance Methods

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods
bool
acquire(cls, lock_file, lock_map)
Make possible to protect a code region using an EXCLUSIVE, non-blocking file lock.
source code
 
release(cls, lock_file, lock_map)
Release a previously acquired lock through acquire_lock().
source code
Properties

Inherited from object: __class__

Method Details

acquire(cls, lock_file, lock_map)
Class Method

source code 

Make possible to protect a code region using an EXCLUSIVE, non-blocking file lock. A lock map (dict) is required in order to register the lock data (usually lock file object) and then unlock it using release_lock().

Parameters:
  • lock_file (string) - path to lock file used for locking
  • lock_map (dict) - lock map (dict object) that can be used to record the lock data in order to unlock it on release_lock().
Returns: bool
True, if lock has been acquired, False otherwise

release(cls, lock_file, lock_map)
Class Method

source code 

Release a previously acquired lock through acquire_lock().

Parameters:
  • lock_file (string) - path to lock file used for locking
  • lock_map (dict) - lock map (dict object) that can be used to record the lock data in order to unlock it on release_lock().