~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/lockfile.py

  • Committer: Robey Pointer
  • Date: 2007-01-02 07:35:34 UTC
  • Revision ID: robey@lag.net-20070102073534-u7tkc8q07xsz9wlv
fewer todos

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
with_lock = util.with_lock('_tlock', 'LockFile')
27
27
 
28
 
MAX_STALE_TIME = 5 * 60
29
 
 
30
28
 
31
29
class LockFile (object):
32
30
    """
46
44
        # thread lock to maintain internal consistency
47
45
        self._tlock = threading.Lock()
48
46
        self._count = 0
49
 
        if os.path.exists(filename):
50
 
            # remove stale locks left over from a previous run
51
 
            if time.time() - os.stat(filename).st_mtime > MAX_STALE_TIME:
52
 
                os.remove(filename)
53
47
    
54
48
    @with_lock
55
49
    def _try_acquire(self):