Send a response back to the proc caller. Refactored out of coreCall for both
regular and exceptional paths.
492689
private void completeCall(ClientResponseImpl response) {
        // if we're keeping track, calculate result size
        if (m_perCallStats.samplingProcedure()) {
            m_perCallStats.setResultSize(response.getResults());
        }
        m_statsCollector.endProcedure(response.getStatus() == ClientResponse.USER_ABORT,
                                      (response.getStatus() != ClientResponse.USER_ABORT) &&
                                      (response.getStatus() != ClientResponse.SUCCESS),
                                      m_perCallStats);
        // allow the GC to collect per-call stats if this proc isn't called for a while
        m_perCallStats = null;

        // send the response to the caller
        // must be done as IRM to CI mailbox for backpressure accounting
        response.setClientHandle(m_clientHandle);
        InitiateResponseMessage irm = InitiateResponseMessage.messageForNTProcResponse(m_ciHandle,
                                                                                       m_ccxn.connectionId(),
                                                                                       response);
        m_mailbox.deliver(irm);

        m_ntProcService.handleNTProcEnd(ProcedureRunnerNT.this);
    }
777381
def send(self, **kwargs):
        
        merged_kwargs = {}
        merged_kwargs.update(self.kwargs)
        merged_kwargs.update(kwargs)
        try:
            self.response = self.session.request(self.method,
                                                self.url, **merged_kwargs)
        except Exception as e:
            self.exception = e
            self.traceback = traceback.format_exc()
        return self
772995
def send_response(self, transaction):
        
        if transaction.cacheHit is False:
            """
            handling response based on the code
            """
            logger.debug("handling response")
            self._handle_response(transaction)
        return transaction
60352
def handle_response(response)
      return super(response)
    rescue ActiveResource::ClientError => exc
      begin
        # ugly code to insert the error_message into response
        error_message = "#{format.decode response.body}"
        if not error_message.nil? or error_message == ""
          exc.response.instance_eval do ||
            @message = error_message
          end
        end
      ensure
        raise exc
      end
    end
1121448
function callResponseMiddleware(err, res1, res2) {
        i -= 1;
        if (i >= 0) {
            var next = self.middlewares[i].response;
            if (typeof next === 'function') {
                next(req, err, res1, res2, callResponseMiddleware);
            } else {
                // skip this middleware if it doesn't implement response
                callResponseMiddleware(err, res1, res2);
            }
        } else {
            callback(req, err, res1, res2);
        }
    }
383758
def methodReturnReceived(self, mret):
        
        d, timeout = self._pendingCalls.get(mret.reply_serial, (None, None))
        if timeout:
            timeout.cancel()
        if d:
            del self._pendingCalls[mret.reply_serial]
            d.callback(mret)
90932
protected void handleInvocationResponse (int reqId, int methodId, Object[] args)
    {
        // look up the invocation marshaller registered for that response
        ListenerMarshaller listener = _listeners.remove(reqId);
        if (listener == null) {
            log.warning("Received invocation response for which we have no registered listener. " +
                        "It is possible that this listener was flushed because the response did " +
                        "not arrive within " + _listenerMaxAge + " milliseconds.",
                        "reqId", reqId, "methId", methodId, "args", args);
            return;
        }

//         log.info("Dispatching invocation response", "listener", listener,
//                  "methId", methodId, "args", args);

        // dispatch the response
        try {
            listener.dispatchResponse(methodId, args);
        } catch (Throwable t) {
            log.warning("Invocation response listener choked", "listener", listener,
                        "methId", methodId, "args", args, t);
        }

        // flush expired listeners periodically
        long now = System.currentTimeMillis();
        if (now - _lastFlushTime > LISTENER_FLUSH_INTERVAL) {
            _lastFlushTime = now;
            flushListeners(now);
        }
    }
604644
def respond_to_missing?(method, _include_private = false)
      if @key && _resource.respond_to?(@key) && (delegate = _resource.send(@key)) && delegate.respond_to?(method.to_s)
        true
      else
        _resource.respond_to?(method.to_s)
      end
    end
621934
public void handleAllHostNTProcedureResponse(ClientResponseImpl clientResponseData) {
        long handle = clientResponseData.getClientHandle();
        ProcedureRunnerNT runner = m_NTProcedureService.m_outstanding.get(handle);
        if (runner == null) {
            hostLog.info("Run everywhere NTProcedure early returned, probably gets timed out.");
            return;
        }
        runner.allHostNTProcedureCallback(clientResponseData);
    }
591857
def process_response(self, request, response):
        """"""
        batcher = PrioritizedBatcher.global_instance()
        if batcher.is_started:
            # May not be started due to strange middleware behavior on first request.
            batcher.commit()

        return response
1347380
public ClientResponseImpl call(Object... paramListIn) {
        m_perCallStats = m_statsCollector.beginProcedure();

        // if we're keeping track, calculate parameter size
        if (m_perCallStats != null) {
            StoredProcedureInvocation invoc = (m_txnState != null ? m_txnState.getInvocation() : null);
            ParameterSet params = (invoc != null ? invoc.getParams() : ParameterSet.fromArrayNoCopy(paramListIn));
            m_perCallStats.setParameterSize(params.getSerializedSize());
        }

        ClientResponseImpl result = coreCall(paramListIn);

        // if we're keeping track, calculate result size
        if (m_perCallStats != null) {
            m_perCallStats.setResultSize(result.getResults());
        }

        m_statsCollector.endProcedure(result.getStatus() == ClientResponse.USER_ABORT,
                                      (result.getStatus() != ClientResponse.USER_ABORT) &&
                                      (result.getStatus() != ClientResponse.SUCCESS),
                                      m_perCallStats);
        // allow the GC to collect per-call stats if this proc isn't called for a while
        m_perCallStats = null;

        return result;
    }
148853
async def respond_rpc(self, msg, _context):
        """"""

        rpc_id = msg.get('response_uuid')
        result = msg.get('result')
        payload = msg.get('response')

        self.service_manager.send_rpc_response(rpc_id, result, payload)
1187870
def call!(request)
      operation = proc {
        app.dispatch(request)
      }
      callback = proc {|result|
        send_response result
        close_connection_after_writing
      }

      #
      # if we don't want to block on slow calls, use EM#defer
      # @see http://eventmachine.rubyforge.org/EventMachine.html#M000486
      #
      if app.non_blocking?
        EventMachine.defer( operation, callback )
      else
        callback.call(operation.call)
      end
    end
357427
def call(self, request=None, *args, **kwargs):
        
        if request is not None:
            self.request = request

        retry = self.request.configuration.retry
        if not isinstance(retry, SimpleRetry):
            raise Error('Currently only the fast retry strategy is supported')

        last_exception = None
        for i in range(0, retry.max_retry):
            try:
                if i > 0:
                    retry.sleep_jitter()

                self.call_once()
                return self.response

            except Exception as ex:
                last_exception = RequestFailed(message='Request failed', cause=ex)
                logger.debug("Request %d failed, exception: %s" % (i, ex))

                # Last exception - throw it here to have a stack
                if i+1 == retry.max_retry:
                    raise last_exception

        raise last_exception
1224341
async def _get_response(self, msg):
        """"""
        try:
            protocol = await self._get_protocol()
            pr = protocol.request(msg)
            r = await pr.response
            return pr, r
        except ConstructionRenderableError as e:
            raise ClientError("There was an error with the request.", e)
        except RequestTimedOut as e:
            await self._reset_protocol(e)
            raise RequestTimeout('Request timed out.', e)
        except (OSError, socket.gaierror, Error) as e:
            # aiocoap sometimes raises an OSError/socket.gaierror too.
            # aiocoap issue #124
            await self._reset_protocol(e)
            raise ServerError("There was an error with the request.", e)
        except asyncio.CancelledError as e:
            await self._reset_protocol(e)
            raise e
648019
def methodResponse(is_ret, *params)

      if is_ret
        resp = params.collect do |param|
          @writer.ele("param", conv2value(param))
        end

        resp = [@writer.ele("params", *resp)]
      else
        if params.size != 1 or params[0] === XMLRPC::FaultException
          raise ArgumentError, "no valid fault-structure given"
        end
        resp = @writer.ele("fault", conv2value(params[0].to_h))
      end


      tree = @writer.document(
               @writer.pi("xml", 'version="1.0"'),
               @writer.ele("methodResponse", resp)
             )

      @writer.document_to_str(tree) + "\n"
    end
508387
def success_response(self, method_resp, **kw):
        
        resp = {
            'status': True,
            'indexing': config.is_indexing(self.working_dir),
            'lastblock': virtualchain_hooks.get_last_block(self.working_dir),
        }

        resp.update(kw)
        resp.update(method_resp)
        
        if self.is_stale():
            # our state is stale
            resp['stale'] = True
            resp['warning'] = 'Daemon has not reindexed since {}'.format(self.last_indexing_time)

        return resp