Construct a request callback for the given request ID.
763324
def _request_callback(self, request_id):
        """"""
        def callback(future):
            # Remove the future from the client requests map
            self._client_request_futures.pop(request_id, None)

            if future.cancelled():
                future.set_exception(JsonRpcRequestCancelled())

            message = {
                'jsonrpc': JSONRPC_VERSION,
                'id': request_id,
            }

            try:
                message['result'] = future.result()
            except JsonRpcException as e:
                log.exception("Failed to handle request %s", request_id)
                message['error'] = e.to_dict()
            except Exception:  # pylint: disable=broad-except
                log.exception("Failed to handle request %s", request_id)
                message['error'] = JsonRpcInternalError.of(sys.exc_info()).to_dict()

            self._consumer(message)

        return callback
658520
def request_show(self, id, **kwargs):
        ""
        api_path = "/api/v2/requests/{id}.json"
        api_path = api_path.format(id=id)
        return self.call(api_path, **kwargs)
1030120
def process_request(self, request_object):
        """"""

        identifier = request_object.identifier

        # Look for the object by its ID and return it
        resource = request_object.entity_cls.get(identifier)
        return ResponseSuccess(Status.SUCCESS, resource)
918771
def request_finished_callback(sender, **kwargs):
    """"""
    logger = logging.getLogger(__name__)
    level = settings.AUTOMATED_LOGGING['loglevel']['request']

    user = get_current_user()
    uri, application, method, status = get_current_environ()

    excludes = settings.AUTOMATED_LOGGING['exclude']['request']
    if status and status in excludes:
        return

    if method and method.lower() in excludes:
        return

    if not settings.AUTOMATED_LOGGING['request']['query']:
        uri = urllib.parse.urlparse(uri).path

    logger.log(level, ('%s performed request at %s (%s %s)' %
                       (user, uri, method, status)).replace("  ", " "), extra={
        'action': 'request',
        'data': {
            'user': user,
            'uri': uri,
            'method': method,
            'application': application,
            'status': status
        }
    })
462187
def _handle_request(self, msg_id, method, params):
        """"""
        try:
            handler = self._dispatcher[method]
        except KeyError:
            raise JsonRpcMethodNotFound.of(method)

        handler_result = handler(params)

        if callable(handler_result):
            log.debug("Executing async request handler %s", handler_result)
            request_future = self._executor_service.submit(handler_result)
            self._client_request_futures[msg_id] = request_future
            request_future.add_done_callback(self._request_callback(msg_id))
        else:
            log.debug("Got result from synchronous request handler: %s", handler_result)
            self._consumer({
                'jsonrpc': JSONRPC_VERSION,
                'id': msg_id,
                'result': handler_result
            })
372807
def retrieve(cls, id, api_key=None, **params):
        """"""
        instance = cls(id, api_key, **params)
        d = instance.refresh()
        return d.addCallback(lambda _: instance)
108082
def register_callback(self):
        """"""

        cid = str(self.__cid)
        self.__cid += 1
        event = queue.Queue()
        self.__callbacks[cid] = event
        return cid, event
1201797
function request(uri, opt, callback) {
    if (typeof opt === 'function') {
        callback = opt;
        opt = {};
    }
    return hyperquest(uri, opt, callback);
}
182514
function(callback) {
        request.get(this.getStatusUrl(), function(err, res, body) {
            if (err) {
                return callback(err);
            }

            body = body || {};
            body.status = res.statusCode;
            body.date = new Date(body.date);

            callback(err, body, res);
        });

        return this;
    }
1115110
def handle_id_request(msg):
    """"""
    node_id = msg.gateway.add_sensor()
    return msg.copy(
        ack=0, sub_type=msg.gateway.const.Internal['I_ID_RESPONSE'],
        payload=node_id) if node_id is not None else None
1175506
def call(self, method, params, callback=None):
        """"""
        cur_id = self._next_id()
        if callback:
            self._callbacks[cur_id] = callback
        self.send({'msg': 'method', 'id': cur_id, 'method': method, 'params': params})
1100877
function(id) {
            var successRequestCallback = this._failedSuccessRequestCallbacks[id];

            return qq.FineUploaderBasic.prototype._manualRetry.call(this, id, successRequestCallback);
        }
571257
def request_info(self, request_id):
        
        request_url = "{}pull-request/{}".format(self.create_basic_url(),
                                                 request_id)

        return_value = self._call_api(request_url)
        return return_value
1050769
def request(self, id, **kwargs):
        
        data = self.get('requests', id, **kwargs)
        return data
772399
function request(req) {
        var clientID = getParam(req, 'client_id')
            , redirectURI = getParam(req, 'redirect_uri')
            , scope = getParam(req, 'scope')
            , state = getParam(req, 'state');

        if (!clientID) {
            throw new AuthorizationError('Missing required parameter: client_id', 'invalid_request');
        }

        if (scope) {
            for (var i = 0, len = separators.length; i < len; i++) {
                var separated = scope.split(separators[i]);
                // only separate on the first matching separator.  this allows for a sort
                // of separator "priority" (ie, favor spaces then fallback to commas)
                if (separated.length > 1) {
                    scope = separated;
                    break;
                }
            }

            if (!Array.isArray(scope)) {
                scope = [scope];
            }
        }

        return {
            clientID: clientID,
            redirectURI: redirectURI,
            scope: scope,
            state: state
        };
    }
1363495
def request_payload(cls, request, request_id):
        ''''''
        payload = {
            'jsonrpc': '2.0',
            'method': request.method,
        }
        # A notification?
        if request_id is not None:
            payload['id'] = request_id
        # Preserve empty dicts as missing params is read as an array
        if request.args or request.args == {}:
            payload['params'] = request.args
        return payload
651398
private void handleRequest(long requestId, Object request, HandlerHolder handler) {
    @SuppressWarnings("unchecked")
    CompletableFuture<Object> responseFuture = handler.handler.apply(request);
    if (responseFuture != null) {
      responseFuture.whenComplete((response, error) -> {
        ThreadContext context = ThreadContext.currentContext();
        if (context == null) {
          this.context.executor().execute(() -> {
            if (error == null) {
              handleRequestSuccess(requestId, response, this.context);
            } else {
              handleRequestFailure(requestId, error, this.context);
            }
          });
        } else {
          if (error == null) {
            handleRequestSuccess(requestId, response, context);
          } else {
            handleRequestFailure(requestId, error, context);
          }
        }
      });
    }
  }