This method performs a registration attempt and triggers either a success notification or a retry,
depending on the result.
507776
@SuppressWarnings("unchecked")
	private void register(final G gateway, final int attempt, final long timeoutMillis) {
		// eager check for canceling to avoid some unnecessary work
		if (canceled) {
			return;
		}

		try {
			log.info("Registration at {} attempt {} (timeout={}ms)", targetName, attempt, timeoutMillis);
			CompletableFuture<RegistrationResponse> registrationFuture = invokeRegistration(gateway, fencingToken, timeoutMillis);

			// if the registration was successful, let the TaskExecutor know
			CompletableFuture<Void> registrationAcceptFuture = registrationFuture.thenAcceptAsync(
				(RegistrationResponse result) -> {
					if (!isCanceled()) {
						if (result instanceof RegistrationResponse.Success) {
							// registration successful!
							S success = (S) result;
							completionFuture.complete(Tuple2.of(gateway, success));
						}
						else {
							// registration refused or unknown
							if (result instanceof RegistrationResponse.Decline) {
								RegistrationResponse.Decline decline = (RegistrationResponse.Decline) result;
								log.info("Registration at {} was declined: {}", targetName, decline.getReason());
							} else {
								log.error("Received unknown response to registration attempt: {}", result);
							}

							log.info("Pausing and re-attempting registration in {} ms", retryingRegistrationConfiguration.getRefusedDelayMillis());
							registerLater(gateway, 1, retryingRegistrationConfiguration.getInitialRegistrationTimeoutMillis(), retryingRegistrationConfiguration.getRefusedDelayMillis());
						}
					}
				},
				rpcService.getExecutor());

			// upon failure, retry
			registrationAcceptFuture.whenCompleteAsync(
				(Void v, Throwable failure) -> {
					if (failure != null && !isCanceled()) {
						if (ExceptionUtils.stripCompletionException(failure) instanceof TimeoutException) {
							// we simply have not received a response in time. maybe the timeout was
							// very low (initial fast registration attempts), maybe the target endpoint is
							// currently down.
							if (log.isDebugEnabled()) {
								log.debug("Registration at {} ({}) attempt {} timed out after {} ms",
									targetName, targetAddress, attempt, timeoutMillis);
							}

							long newTimeoutMillis = Math.min(2 * timeoutMillis, retryingRegistrationConfiguration.getMaxRegistrationTimeoutMillis());
							register(gateway, attempt + 1, newTimeoutMillis);
						}
						else {
							// a serious failure occurred. we still should not give up, but keep trying
							log.error("Registration at {} failed due to an error", targetName, failure);
							log.info("Pausing and re-attempting registration in {} ms", retryingRegistrationConfiguration.getErrorDelayMillis());

							registerLater(gateway, 1, retryingRegistrationConfiguration.getInitialRegistrationTimeoutMillis(), retryingRegistrationConfiguration.getErrorDelayMillis());
						}
					}
				},
				rpcService.getExecutor());
		}
		catch (Throwable t) {
			completionFuture.completeExceptionally(t);
			cancel();
		}
	}
867629
def retry(self, msg, e, retry_num, waittime):
        ''' 
        '''
        self.msg.error_message(msg)
        self.msg.error_message(e)
        self.msg.error_message("Attempt number " + str(retry_num) + ". Retrying in " + str(waittime) + " seconds.")
        time.sleep(waittime)
317715
def on_success(self, retval, task_id, args, kwargs):
        """"""
        super().on_success(retval, task_id, args, kwargs)
        self._operation_run.on_success()
157806
def register(self, result):
        
        if self._stopped:
            raise ReactorStopped()
        self._results.add(result)
440282
function(err, result) {
      if (err && !util.isError(err)) {
        err = new Error(err);
      }
      if (callback) callback(err, result);
    }
809041
def successful(self):
        """"""
        for result in self.results:
            if result.code == ResultCode.FAILED:
                return False
        return True
1058084
function() {
        var _status = STATUS_PENDING;
        var _args;
        var _callbacks = {
            success: [],
            fail: [],
            done: []
        };

        function _registerCallback(resultType, callback) {
            if (typeof callback !== 'function') {
                //Invalid input args. Throw an error.
                throw 'Invalid argument: callback. Must be a function.';
            }

            if (_status !== STATUS_PENDING) {
                if (_status === resultType || resultType === RESULT_TYPE_DONE) {
                    // Promise has already been satisfied. Just invoke the
                    // callback.
                    callback.apply(null, _args);
                }
            } else {
                // Promise has not yet been satisfied. Remember it, and
                // invoke when ready.
                _callbacks[resultType].push(callback);
            }
        }

        function _satisfy(resultType, args) {
            if (_status !== STATUS_PENDING) {
                return;
            }
            _args = args;
            _status = resultType;

            function doCallback(item, index) {
                item.apply(null, _args);
            }

            //Trigger any callbacks that have been queued.
            _callbacks[resultType].forEach(doCallback);
            _callbacks.done.forEach(doCallback);

            //Clear out any callback references.
            _callbacks.succes = [];
            _callbacks.fail = [];
            _callbacks.done = [];
        }

        var _promise = {
            /*
             * Invoked to allow callers to register callbacks that will be
             * triggered on completion of the deferred activity. This callback
             * will be triggered whether or not the completion was successful.
             */
            done: function(callback) {
                _registerCallback(RESULT_TYPE_DONE, callback);
                return (_promise);
            },

            /*
             * Invoked to allow callers to register callbacks that will be
             * triggered on successful completion of the deferred activity.
             */
            success: function(callback) {
                _registerCallback(STATUS_SUCCESS, callback);
                return (_promise);
            },

            /*
             * Invoked to allow callers to register callbacks that will be
             * triggered on unsuccessful completion of the deferred activity.
             */
            fail: function(callback) {
                _registerCallback(STATUS_FAIL, callback);
                return (_promise);
            },

            /* 
             * Returns the results returned by the deferred activity.
             */
            results: function() {
                return _args;
            }
        }

        var deferredObject = {
            /*
             * Allows a callback to be registered that will be called once the
             * deferred has been resolved or rejected.
             */
            done: _promise.done,

            /*
             * Allows a callback to be registered that will be called once the
             * deferred has been resolved.
             */
            success: _promise.success,

            /*
             * Allows a callback to be registered that will be called once the
             * deferred has been rejected.
             */
            fail: _promise.fail,

            /*
             * Fulfills the promise by resolving it.
             */
            resolve: function() {
                _satisfy(STATUS_SUCCESS, Array.prototype.slice.call(arguments, 0));
            },

            /*
             * Fulfills the promise by rejecting it.
             */
            reject: function() {
                _satisfy(STATUS_FAIL, Array.prototype.slice.call(arguments, 0));
            },

            /*
             * Gets a promise associated with the deferred object.
             */
            promise: function() {
                return Object.create(_promise);
            },

            /*
             * Generates a callback that resolves/rejects the deferred object
             * based on the success/failure of an operation, determined by the
             * first argument in.
             */
            getResolver: function() {
                var ctxArgs = Array.prototype.slice.call(arguments, 0);
                return function(err, data) {
                    if (!err) {
                        var args = Array.prototype.slice.call(arguments, 1);
                        deferredObject.resolve.apply(null,
                            ctxArgs.concat(args));
                    } else {
                        deferredObject.reject.apply(null,
                            ctxArgs.concat([err]));
                    }
                };
            },

            /*
             * Generates a callback that resolves/rejects the deferred after a
             * specified number of steps have been completed, indicated by the
             * invocation of stepComplete().
             */
            getMultiStepResolver: function(count) {
                var _count = count;
                var ctxArgs = Array.prototype.slice.call(arguments, 1);

                // If the step count is zero, resolve immediately.
                if (_count === 0) {
                    deferredObject.resolve.apply(null, ctxArgs);
                }

                return {
                    /*
                     * Indicates that a specific step was completed. The
                     * promise will be treated as resolved if this method
                     * is invoked a given number of times.
                     */
                    stepComplete: function() {
                        var ca
                        _count--;
                        if (_count === 0) {
                            var args = Array.prototype.slice.call(arguments, 0);
                            deferredObject.resolve.apply(null,
                                ctxArgs.concat(args));
                        }
                    },

                    /*
                     * Rejects the deferred object without waiting for any
                     * further processing.
                     */
                    reject: function() {
                        var args = Array.prototype.slice.call(arguments, 0);
                        deferredObject.reject.apply(null, ctxArgs.concat(args));
                    }
                }
            }
        };

        return deferredObject;
    }
1050519
def on_retry(self, exc, task_id, args, kwargs, einfo):
        
        super(LoggedTask, self).on_retry(exc, task_id, args, kwargs, einfo)
        log.warning('[{}] retried due to {}'.format(task_id, getattr(einfo, 'traceback', None)))
1108791
def success(self, msg, *args, **kw):
        """"""
        if self.isEnabledFor(SUCCESS):
            self._log(SUCCESS, msg, args, **kw)
37887
protected void success(T result) {
    this.result = result;
    this.completed = true;
    for (Callback<T, E> callback : toBeNotified) {
      callback.success(result);
    }
  }
10780
public void notifyFailure(final Callback<?> callback, final Throwable error) {
    invokeLater(new Runnable() {
      public void run() {
        callback.onFailure(error);
      }
    });
  }
558896
public void onFailure(JoynrException newException) {
        exception = newException;
        status = new RequestStatus(RequestStatusCode.ERROR);
        try {
            statusLock.lock();
            statusLockChangedCondition.signalAll();
        } finally {
            statusLock.unlock();
        }
    }
531374
async def _registration_completed(self, message):
        
        if not self.registered:
            # Re-enable throttling.
            self.registered = True
            self.connection.throttle = True

            target = message.params[0]
            fakemsg = self._create_message('NICK', target, source=self.nickname)
            await self.on_raw_nick(fakemsg)
72460
function(err, model, response, options){
  if (options.cb){
    options.cb(err, model, response);
  }
  if (err){
    model.trigger('error', err, model, options);
  }
}
88340
private void retry(String subTaskSpecId, MonitorEntry monitorEntry, TaskStatusPlus lastFailedTaskStatus)
  {
    synchronized (startStopLock) {
      if (running) {
        final SubTaskSpec<T> spec = monitorEntry.spec;
        final T task = spec.newSubTask(monitorEntry.taskHistory.size() + 1);
        log.info("Submitting a new task[%s] for retrying spec[%s]", task.getId(), spec.getId());
        indexingServiceClient.runTask(task);
        incrementNumRunningTasks();

        runningTasks.put(
            subTaskSpecId,
            monitorEntry.withNewRunningTask(
                task,
                indexingServiceClient.getTaskStatus(task.getId()).getStatus(),
                lastFailedTaskStatus
            )
        );
      }
    }
  }
914548
def on_success(self, retval, task_id, args, kwargs):
        
        if self.request.is_eager:
            # Store the result because celery wouldn't otherwise
            self.update_state(task_id, SUCCESS, retval)
864317
def activate(request, activation_key=None):
    
    utils.activate_user(activation_key)
    # if not activated
    success_url = utils.get_settings('REGISTRATION_API_ACTIVATION_SUCCESS_URL')
    if success_url is not None:
        return HttpResponseRedirect(success_url)