Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(4)  |  Call(2)  |  Derive(0)  |  Import(2)
Remove files ending with `suffix` from `lockdir` if they are older then
`max_lock_time` seconds.
It will not cleanup on every call if `force` is ``False``.

        def cleanup_lockdir(lockdir, suffix='.lck', max_lock_time=300, force=True):
    """
    Remove files ending with `suffix` from `lockdir` if they are older then
    `max_lock_time` seconds.
    It will not cleanup on every call if `force` is ``False``.
    """
    global _cleanup_counter
    _cleanup_counter += 1
    if not force and _cleanup_counter % 50 != 0:
        return
    expire_time = time.time() - max_lock_time
    if not os.path.exists(lockdir):
        return
    if not os.path.isdir(lockdir):
        log.warn('lock dir not a directory: %s', lockdir)
        return
    for entry in os.listdir(lockdir):
        name = os.path.join(lockdir, entry)
        try:
            if os.path.isfile(name) and name.endswith(suffix):
                if os.path.getmtime(name) < expire_time:
                    try:
                        os.unlink(name)
                    except IOError, ex:
                        log.warn('could not remove old lock file %s: %s', name, ex)
        except OSError, e:
            # some one might have removed the file (ENOENT)
            # or we don't have permissions to remove it (EACCES)
            if e.errno in (errno.ENOENT, errno.EACCES):
                # ignore
                pass
            else:
                raise e
        


src/m/a/mapproxy-HEAD/mapproxy/cache/base.py   mapproxy(Download)
from contextlib import contextmanager
 
from mapproxy.util.lock import FileLock, cleanup_lockdir, DummyLock
 
class CacheBackendError(Exception):
            return DummyLock()
        lock_filename = self.lock_filename(tile)
        cleanup_lockdir(self.lock_dir, max_lock_time=self.lock_timeout + 10,
            force=False)
        return FileLock(lock_filename, timeout=self.lock_timeout,

src/m/a/MapProxy-1.6.0/mapproxy/cache/base.py   MapProxy(Download)
from contextlib import contextmanager
 
from mapproxy.util.lock import FileLock, cleanup_lockdir, DummyLock
 
class CacheBackendError(Exception):
            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)