def try_cache_key_lock(cache_dir, key): cache = Directory(path=cache_dir) try: cache.lock_key(key, timeout=0) cache.unlock_key(key) except: sys.exit(1) sys.exit(0)
def test_raises_with_key_lock_unlock_on_invalid_path(self): with TempDir() as cache_dir: cache = Directory(path=cache_dir) self.assertRaises(KeyNotFound, lambda: cache.lock_key('doesntexist')) self.assertRaises(KeyNotFound, lambda: cache.unlock_key('doesntexist'))