Пример #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
 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)