示例#1
0
 def lock(self, tile):
     """
     Returns a lock object for this tile.
     """
     lock_filename = self.lock_filename(tile)
     cleanup_lockdir(self.lock_dir, force=False)
     return FileLock(lock_filename, timeout=self.lock_timeout,
         remove_on_unlock=True)
示例#2
0
 def lock(self, tile):
     """
     Returns a lock object for this tile.
     """
     if getattr(self, 'locking_disabled', False):
         return DummyLock()
     lock_filename = self.lock_filename(tile)
     cleanup_lockdir(self.lock_dir, force=False)
     return FileLock(lock_filename, timeout=self.lock_timeout,
         remove_on_unlock=True)
示例#3
0
文件: base.py 项目: imclab/mapproxy
 def lock(self, tile):
     """
     Returns a lock object for this tile.
     """
     if getattr(self, 'locking_disabled', False):
         return DummyLock()
     lock_filename = self.lock_filename(tile)
     cleanup_lockdir(self.lock_dir, force=False)
     return FileLock(lock_filename, timeout=self.lock_timeout,
         remove_on_unlock=True)
示例#4
0
 def lock(self, tile):
     """
     Returns a lock object for this tile.
     """
     if getattr(self, 'locking_disabled', False):
         return DummyLock()
     lock_filename = self.lock_filename(tile)
     try:
         cleanup_lockdir(self.lock_dir, force=False)
     except WindowsError, ex:
         log.warn("WindowsError: %s", ex)
示例#5
0
    def test_lock_cleanup(self):
        old_lock_file = os.path.join(self.lock_dir, 'lock_old.lck')
        l = FileLock(old_lock_file)
        l.lock()
        l.unlock()
        mtime = os.stat(old_lock_file).st_mtime
        mtime -= 7*60
        os.utime(old_lock_file, (mtime, mtime))

        l = self._create_lock()
        l.unlock()
        assert os.path.exists(old_lock_file)
        assert os.path.exists(self.lock_file)
        cleanup_lockdir(self.lock_dir)

        assert not os.path.exists(old_lock_file)
        assert os.path.exists(self.lock_file)
示例#6
0
    def test_lock_cleanup(self):
        old_lock_file = os.path.join(self.lock_dir, 'lock_old.lck')
        l = FileLock(old_lock_file)
        l.lock()
        l.unlock()
        mtime = os.stat(old_lock_file).st_mtime
        mtime -= 7 * 60
        os.utime(old_lock_file, (mtime, mtime))

        l = self._create_lock()
        l.unlock()
        assert os.path.exists(old_lock_file)
        assert os.path.exists(self.lock_file)
        cleanup_lockdir(self.lock_dir)

        assert not os.path.exists(old_lock_file)
        assert os.path.exists(self.lock_file)