Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes
MoinMoin.util.lock.LazyWriteLock Class Reference
Inheritance diagram for MoinMoin.util.lock.LazyWriteLock:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.util.lock.LazyWriteLock:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def acquire
def release
def exists
def isExpired
def expire
def isLocked

Public Attributes

 readlocktimeout
 dir
 timeout
 lockDir

Static Public Attributes

string fileName = 'write_lock'
 timerClass = Timer

Private Attributes

 _locked

Detailed Description

Lazy Write lock

See WriteLock and LazyReadLock docs.

Definition at line 362 of file lock.py.


Constructor & Destructor Documentation

def MoinMoin.util.lock.LazyWriteLock.__init__ (   self,
  dir,
  timeout = None 
)
Init a write lock

@param dir: the lock directory. Since this lock uses a empty
    filename, the dir is the lockDir.
@param timeout: while trying to acquire, the lock will expire
    other exclusive locks older than timeout.
    WARNING: because of file system timing limitations, timeouts
    must be at least 2 seconds.

Reimplemented from MoinMoin.util.lock.ExclusiveLock.

Definition at line 367 of file lock.py.

00367 
00368     def __init__(self, dir, timeout=None):
00369         if sys.platform == 'win32':
00370             WriteLock.__init__(self, dir, timeout)
00371         else: # POSIX
00372             self._locked = False


Member Function Documentation

def MoinMoin.util.lock.LazyWriteLock.acquire (   self,
  timeout = None 
)
Acquire an exclusive write lock

Try to acquire an exclusive lock, then try to expire existing
read locks. If timeout has not passed, the lock is acquired.
Otherwise, the exclusive lock is released and the lock is not
acquired.

Return True if lock acquired, False otherwise.

Reimplemented from MoinMoin.util.lock.WriteLock.

Definition at line 373 of file lock.py.

00373 
00374     def acquire(self, timeout=None):
00375         if sys.platform == 'win32':
00376             return WriteLock.acquire(self, timeout)
00377         else: # POSIX
00378             self._locked = True
00379             return True

Reimplemented from MoinMoin.util.lock.ExclusiveLock.

Definition at line 386 of file lock.py.

00386 
00387     def exists(self):
00388         if sys.platform == 'win32':
00389             return WriteLock.exists(self)
00390         else: # POSIX
00391             return True

Return True if the lock is expired or missing; False otherwise. 

Reimplemented from MoinMoin.util.lock.ExclusiveLock.

Definition at line 398 of file lock.py.

00398 
00399     def expire(self):
00400         if sys.platform == 'win32':
00401             return WriteLock.expire(self)
00402         else: # POSIX
00403             return True
Return True if too old or missing; False otherwise

TODO: Since stat returns times using whole seconds, this is
quite broken. Maybe use OS specific calls like Carbon.File on
Mac OS X?

Reimplemented from MoinMoin.util.lock.ExclusiveLock.

Definition at line 392 of file lock.py.

00392 
00393     def isExpired(self):
00394         if sys.platform == 'win32':
00395             return WriteLock.isExpired(self)
00396         else: # POSIX
00397             return True

def MoinMoin.util.lock.ExclusiveLock.isLocked (   self) [inherited]

Definition at line 134 of file lock.py.

00134 
00135     def isLocked(self):
00136         return self._locked

Release the lock 

Reimplemented from MoinMoin.util.lock.ExclusiveLock.

Definition at line 380 of file lock.py.

00380 
00381     def release(self):
00382         if sys.platform == 'win32':
00383             return WriteLock.release(self)
00384         else:  # POSIX
00385             self._locked = False


Member Data Documentation

Reimplemented from MoinMoin.util.lock.ExclusiveLock.

Definition at line 371 of file lock.py.

Definition at line 89 of file lock.py.

string MoinMoin.util.lock.WriteLock.fileName = 'write_lock' [static, inherited]

Reimplemented from MoinMoin.util.lock.ExclusiveLock.

Definition at line 197 of file lock.py.

Reimplemented in MoinMoin.util.lock.ReadLock.

Definition at line 94 of file lock.py.

Definition at line 211 of file lock.py.

Definition at line 92 of file lock.py.

Definition at line 77 of file lock.py.


The documentation for this class was generated from the following file: