Package entropy :: Module misc :: Class FlockFile

Class FlockFile

source code


Of flock() operations on a file.

Nested Classes
  FlockFileInitFailure
FlockFile initialization failure exception.
Instance Methods
 
__init__(self, file_path, fd=None, fobj=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
shared(*args, **kwds)
Acquire the lock in shared mode (context manager).
source code
 
exclusive(*args, **kwds)
Acquire the lock in exclusive mode.
source code
 
acquire_shared(self)
Acquire the lock in shared mode.
source code
bool
try_acquire_shared(self)
Acquire the lock in shared mode, non blocking.
source code
 
acquire_exclusive(self)
Acquire the lock in exclusive mode.
source code
bool
try_acquire_exclusive(self)
Acquire the lock in exclusive mode, non blocking.
source code
 
promote(self)
Promote a lock acquired in shared mode to exclusive mode.
source code
 
try_promote(self)
Promote a lock acquired in shared mode to exclusive mode, non blocking.
source code
 
demote(self)
Demote a lock acquired in exclusive mode to shared mode.
source code
 
release(self)
Release the lock previously acquired.
source code
 
get_path(self)
Return the file path associated with this instance.
source code
 
get_file(self)
Get the underlying File Object.
source code
 
close(self)
Close the underlying file object.
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, file_path, fd=None, fobj=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

shared(*args, **kwds)

source code 

Acquire the lock in shared mode (context manager).

Decorators:
  • @contextlib.contextmanager

exclusive(*args, **kwds)

source code 

Acquire the lock in exclusive mode.

Decorators:
  • @contextlib.contextmanager

try_acquire_shared(self)

source code 

Acquire the lock in shared mode, non blocking.

Returns: bool
True, if lock acquired.

try_acquire_exclusive(self)

source code 

Acquire the lock in exclusive mode, non blocking.

Returns: bool
True, if lock acquired.

get_file(self)

source code 

Get the underlying File Object. Use at your own risk.