Package oauth2client :: Module locked_file :: Class LockedFile
[hide private]
[frames] | no frames]

Class LockedFile

source code


Represent a file that has exclusive access.

Instance Methods [hide private]
 
__init__(self, filename, mode, fallback_mode, use_native_locking=True)
Construct a LockedFile.
source code
 
filename(self)
Return the filename we were constructed with.
source code
 
file_handle(self)
Return the file_handle to the opened file.
source code
 
is_locked(self)
Return whether we successfully locked the file.
source code
 
open_and_lock(self, timeout=0, delay=0.05)
Open the file, trying to lock it.
source code
 
unlock_and_close(self)
Unlock and close a file.
source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, filename, mode, fallback_mode, use_native_locking=True)
(Constructor)

source code 
Construct a LockedFile.

Args:
  filename: string, The path of the file to open.
  mode: string, The mode to try to open the file with.
  fallback_mode: string, The mode to use if locking fails.
  use_native_locking: bool, Whether or not fcntl/win32 locking is used.

Decorators:
  • @util.positional(4)
Overrides: object.__init__

open_and_lock(self, timeout=0, delay=0.05)

source code 
Open the file, trying to lock it.

Args:
  timeout: float, The number of seconds to try to acquire the lock.
  delay: float, The number of seconds to wait between retry attempts.

Raises:
  AlreadyLockedException: if the lock is already acquired.
  IOError: if the open fails.