def test_common_lockfile(self): with self.getTestDir() as fdir: fp = os.path.join(fdir, 'hehe.lock') # Ensure that our yield is None with s_common.lockfile(fp) as cm: self.none(cm)
def shared(path): ''' A context manager for locking a potentially shared vault. Args: path (str): Path to the vault. Example: with s_vault.shared('~/.syn/vault') as vault: dostuff() Yields: Vault: A Vault object. ''' full = s_common.genpath(path) lock = os.path.join(full, 'synapse.lock') with s_common.lockfile(lock): with Vault(full) as vault: yield vault