Call the given callback if or when the connected deferred succeeds.
4988
def on_success(self, fn, *args, **kwargs):
        

        self._callbacks.append((fn, args, kwargs))

        result = self._resulted_in
        if result is not _NOTHING_YET:
            self._succeed(result=result)
676609
function promiseTry(callback) {
  try {
    const maybePromise = callback();

    if (isPromise(maybePromise)) {
      return maybePromise;
    } else {
      return Promise.resolve(maybePromise);
    }
  } catch (err) {
    return Promise.reject(err);
  }
}
73651
function(options, callback) {
    // Create a promise to defer to later
    var deferred = Bluebird.defer();

    // Fire the request
    request(this._buildRequestOptions(options), function(err, response, body) {
      // Handle Errors
      if (err) {
        // Usually a connection error (server unresponsive)
        err = new MuniError(err.message || 'Internal Server Error', err.code || 500);
      } else if (response.statusCode >= 400) {
        // Usually an intentional error from the server
        err = new MuniError(this._extractError(body), response.statusCode);
      }
      if (err) {
        debug.warn('Adapter Request Error with Code: %d', err.code);
        callback && callback(err);
        return deferred.reject(err);
      }

      // Handle Success
      debug.info('Adapter Request Sent with code: %d', response.statusCode);
      callback && callback(null, body);
      return deferred.resolve(body);
    }.bind(this));

    return deferred.promise;
  }
82616
@SuppressWarnings("rawtypes")
    private void synchronousInvokeCallback(Callable call) {

        Future future = streamingSlopResults.submit(call);

        try {
            future.get();

        } catch(InterruptedException e1) {

            logger.error("Callback failed", e1);
            throw new VoldemortException("Callback failed");

        } catch(ExecutionException e1) {

            logger.error("Callback failed during execution", e1);
            throw new VoldemortException("Callback failed during execution");
        }

    }
535373
def call_func(self, *args, **kwargs):
        """"""
        asyncio.gather(
            self.cron(*args, **kwargs),
            loop=self.loop, return_exceptions=True
            ).add_done_callback(self.set_result)
434909
def _run_callback(
        self, callback: Callable, *args: Any, **kwargs: Any
    ) -> "Optional[Future[Any]]":
        
        try:
            result = callback(*args, **kwargs)
        except Exception:
            self.handler.log_exception(*sys.exc_info())
            self._abort()
            return None
        else:
            if result is not None:
                result = gen.convert_yielded(result)
                assert self.stream is not None
                self.stream.io_loop.add_future(result, lambda f: f.result())
            return result
1035896
function done(err) {
            if (err != null) {
                process.exitCode = 1
                console.error(`  ERROR: ${err.message}`)
            }
            if (options.verbose && err == null) {
                console.log("  Done.")
            }

            next()

            if (callback != null) {
                callback(err)
            }
        }
815555
function (func) {
		if (!(this instanceof Deferred)) {
			return new Deferred();
		}
		this._doneFuncs = [];
		this._failFuncs = [];
		this._resultArgs = null;
		this._status = '';
		// Check for option `function` -- call it with this as context and as first
		// parameter, as specified in jQuery API.
		if (func) {
			func.call(this, this);
		}
	}
636242
def connect_async(self, conn_id, connection_string, callback):
        """"""

        future = self._loop.launch_coroutine(self._adapter.connect(conn_id, connection_string))
        future.add_done_callback(lambda x: self._callback_future(conn_id, x, callback))
676486
def _execute_callback_async(self, callback, data):
        
        if asyncio.iscoroutine(callback):
            asyncio.ensure_future(
                callback(rtm_client=self, web_client=self._web_client, data=data)
            )
        else:
            asyncio.ensure_future(
                asyncio.coroutine(callback)(
                    rtm_client=self, web_client=self._web_client, data=data
                )
            )
462368
@JsIgnore
  public static void onReady(Runnable callback) {
    if (isReady) {
      callback.run();
      return;
    }

    onReadyCallbacks.push(callback);
  }
954126
def on(self, evt, func):
        ''''''
        if evt not in self._callbacks:
            raise NotImplementedError('callback "%s"' % evt)
        else:
            self._callbacks[evt] = func
53457
function callbackOnce(err, arg) {
            var cb = callback;
            callback = null;
            if (cb) { cb(err, arg); }
        }
223531
function done(error) {
      global.clearTimeout(timer);
      eventLoop.removeListener('tick', ontick);
      eventLoop.removeListener('idle', done);
      eventLoop.browser.removeListener('error', done);

      --eventLoop.waiting;
      try {
        callback(error);
      } catch (error) {
        // If callback makes an assertion that fails, we end here.
        // If we throw error synchronously, it gets swallowed.
        setImmediate(function() {
          throw error;
        });
      }
    }
179626
def wait_return(self, callback):
        """"""
        if self.check_recv():
            return callback(self)
        _t = threading.Thread(target=self._wait_non_ressources, args=(callback,))  # noqa: E501
        _t.setDaemon(True)
        _t.start()
623341
def add_done_callback(self, fn):  # pylint: disable=invalid-name
        
        if self._operation.done:
            _try_callback(self, fn)
        else:
            self._queue.put(dill.dumps(fn))
            if self._process is None:
                self._process = mp.Process(target=self._execute_tasks)
                self._process.start()
499919
function onConnect(err) {
    if (err) {
      DEBUG("connect error", err)
      return cb(err)
    }

    DEBUG("connected")

    channel.sendMessage({
      type: "request",
      name: "connect",
      to:   "server",
      id:   "0",
      body: {
        key: config.key
      }
    })
  }