@contextlib.contextmanager
    def gen_lock(self, lock_type='update'):
        '''
        Set and automatically clear a lock
        '''
        lock_set = False
        try:
            self._lock(lock_type=lock_type, failhard=True)
            lock_set = True
            yield
        except (OSError, __HOLE__, GitLockError) as exc:
            raise GitLockError(exc.errno, exc.strerror)
        finally:
            if lock_set:
                self.clear_lock(lock_type=lock_type)
dataset/ETHPy150Open saltstack/salt/salt/utils/gitfs.py/GitProvider.gen_lock