oauth2client.locked_file
index
/home/jcgregorio/projects/clean/oauth2client/locked_file.py

Locked file interface that should work on Unix and Windows pythons.
 
This module first tries to use fcntl locking to ensure serialized access
to a file, then falls back on a lock file if that is unavialable.
 
Usage:
    f = LockedFile('filename', 'r+b', 'rb')
    f.open_and_lock()
    if f.is_locked():
      print 'Acquired filename with r+b mode'
      f.file_handle().write('locked data')
    else:
      print 'Aquired filename with rb mode'
    f.unlock_and_close()

 
Modules
       
errno
fcntl
logging
os
time

 
Classes
       
__builtin__.object
LockedFile
exceptions.Exception(exceptions.BaseException)
AlreadyLockedException

 
class AlreadyLockedException(exceptions.Exception)
    Trying to lock a file that has already been locked by the LockedFile.
 
 
Method resolution order:
AlreadyLockedException
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
class LockedFile(__builtin__.object)
    Represent a file that has exclusive access.
 
  Methods defined here:
__init__(self, filename, mode, fallback_mode, use_fcntl=True)
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_fcntl: string, Whether or not fcntl-based locking should be used.
file_handle(self)
Return the file_handle to the opened file.
filename(self)
Return the filename we were constructed with.
is_locked(self)
Return whether we successfully locked the file.
open_and_lock(self, timeout=0, delay=0.050000000000000003)
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.
unlock_and_close(self)
Unlock and close a file.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Data
        __author__ = 'cache@google.com (David T McWherter)'
logger = <logging.Logger instance>

 
Author
        cache@google.com (David T McWherter)