code: func (l *locker) Lock(s statemgr.Locker, reason string) error {
  	l.mu.Lock()
  	defer l.mu.Unlock()
  
  	l.state = s
  
  	ctx, cancel := context.WithTimeout(l.ctx, l.timeout)
  	defer cancel()
  
  	lockInfo := state.NewLockInfo()
  	lockInfo.Operation = reason
  
  	err := slowmessage.Do(LockThreshold, func() error {
  		id, err := statemgr.LockWithContext(ctx, s, lockInfo)
  		l.lockID = id
  		return err
  	}, func() {
  		if l.ui != nil {
  			l.ui.Output(l.color.Color(LockMessage))
  		}
  	})
  
  	if err != nil {
  		return errwrap.Wrapf(strings.TrimSpace(LockErrorMessage), err)
  	}
  
  	return nil
  }
docs: // Locker locks the given state and outputs to the user if locking is taking
  // longer than the threshold. The lock is retried until the context is
  // cancelled.