Package entropy :: Module locks :: Class ResourceLock

Class ResourceLock

source code


Generic Entropy Resource Lock abstract class.

Instance Methods
 
__init__(self, output=None)
Object constructor.
source code
 
acquire_exclusive(self)
Acquire the resource in exclusive blocking mode.
source code
 
acquire_shared(self)
Acquire the resource in shared blocking mode.
source code
 
exclusive(*args, **kwds)
Acquire an exclusive file lock for this repository (context manager).
source code
 
is_already_acquired(self)
Return whether the current thread has already acquired the lock (which is reentrant).
source code
 
path(self)
Return the path to the lock file.
source code
 
release(self)
Release the previously acquired resource.
source code
 
shared(*args, **kwds)
Acquire a shared file lock for this repository (context manager).
source code
 
try_acquire_exclusive(self)
Acquire the resource in exclusive non-blocking mode.
source code
 
try_acquire_shared(self)
Acquire the resource in shared non-blocking mode.
source code
 
wait_exclusive(self)
Try to acquire the resource in non-blocking mode, on failure, print a warning and then acquire the resource in blocking mode.
source code
 
wait_shared(self)
Try to acquire the resource in non-blocking mode, on failure, print a warning and then acquire the resource in blocking mode.
source code

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

Properties

Inherited from object: __class__

Method Details

__init__(self, output=None)
(Constructor)

source code 

Object constructor.

Parameters:
  • output (entropy.output.TextInterface or None) - a TextInterface interface
Overrides: object.__init__

exclusive(*args, **kwds)

source code 

Acquire an exclusive file lock for this repository (context manager).

Decorators:
  • @contextlib.contextmanager

shared(*args, **kwds)

source code 

Acquire a shared file lock for this repository (context manager).

Decorators:
  • @contextlib.contextmanager

try_acquire_exclusive(self)

source code 

Acquire the resource in exclusive non-blocking mode. Return True if resource is acquired, False otherwise.

try_acquire_shared(self)

source code 

Acquire the resource in shared non-blocking mode. Return True if resource is acquired, False otherwise.