예제 #1
0
파일: disk.go 프로젝트: snailwalker/juju
// It appears that sometimes the lock is not cleared when we expect it to be.
// Capture and log any errors from the Unlock method and retry a few times.
func unlockEnvironmentLock(lock *fslock.Lock) {
	attempts := utils.AttemptStrategy{
		Delay: 50 * time.Millisecond,
		Min:   10,
	}
	var err error
	for a := attempts.Start(); a.Next(); {
		err = lock.Unlock()
		if err == nil {
			return
		}
		if a.HasNext() {
			logger.Debugf("failed to unlock configstore lock: %s, retrying", err)
		}
	}
	logger.Errorf("unable to unlock configstore lock: %s", err)
}
예제 #2
0
파일: util_test.go 프로젝트: kat-co/utils
func assertCanLock(c *gc.C, lock *fslock.Lock) {
	err := lock.Lock("")
	c.Assert(err, gc.IsNil)
	c.Assert(lock.IsLocked(), gc.Equals, true)
}