code: func (s *Scheduler) waitUntilStackOperationComplete(lock *pglock.AdvisoryLock, wait func() error) error {
  	errCh := make(chan error)
  	go func() { errCh <- wait() }()
  
  	var err error
  	select {
  	case <-s.after(stackOperationTimeout):
  		err = errors.New("timed out waiting for stack operation to complete")
  	case err = <-errCh:
  	}
  
  	return err
  }
docs: // waitUntilStackOperationComplete waits until wait returns, or it times out.