Send request thread
973418
def __send_run(self):
        
        while not self.__end.is_set():
            try:
                with Connection(userid=self.__prefix + self.__epid,
                                password=self.__passwd,
                                virtual_host=self.__vhost,
                                heartbeat=self.__heartbeat,
                                connect_timeout=self.__socket_timeout,
                                operation_timeout=self.__socket_timeout,
                                ssl=self.__get_ssl_context(self.__sslca),
                                host=self.__host) as conn,\
                        conn.channel(auto_encode_decode=False) as channel:

                    self.__send_channel = channel
                    self.__send_exc_clear(log_if_exc_set='reconnected')
                    self.__send_ready.set()
                    try:
                        self.__send_ready_callback(self.__send_exc_time)

                        while not self.__end.is_set():
                            with self.__send_lock:
                                try:
                                    # deal with any incoming messages (AMQP protocol only, not QAPI)
                                    conn.drain_events(0)
                                except (BlockingIOError, SocketTimeout):
                                    pass
                                conn.heartbeat_tick()
                            # idle
                            self.__end.wait(.25)
                    finally:
                        # locked so can make sure another call to send() is not made whilst shutting down
                        with self.__send_lock:
                            self.__send_ready.clear()

            except exceptions.AccessRefused:
                self.__send_log_set_exc_and_wait('Access Refused (Credentials already in use?)')
            except exceptions.ConnectionForced:
                self.__send_log_set_exc_and_wait('Disconnected by broker (ConnectionForced)')
            except SocketTimeout:
                self.__send_log_set_exc_and_wait('SocketTimeout exception.  wrong credentials, vhost or prefix?')
            except SSLError:
                self.__send_log_set_exc_and_wait('ssl.SSLError Bad Certificate?')
            except (exceptions.AMQPError, SocketError):
                self.__send_log_set_exc_and_wait('amqp/transport failure, sleeping before retry')
            except:
                self.__send_log_set_exc_and_wait('unexpected failure, exiting', wait_seconds=0)
                break
        logger.debug('finished')
1109898
private <T extends Request, U> void sendRequest(T request, BiFunction<Request, Connection, CompletableFuture<U>> sender, Connection connection, Throwable error, CompletableFuture<U> future) {
    if (open) {
      if (error == null) {
        if (connection != null) {
          LOGGER.trace("{} - Sending {}", id, request);
          sender.apply(request, connection).whenComplete((r, e) -> {
            if (e != null || r != null) {
              handleResponse(request, sender, connection, (Response) r, e, future);
            } else {
              future.complete(null);
            }
          });
        } else {
          future.completeExceptionally(new ConnectException("Failed to connect to the cluster"));
        }
      } else {
        LOGGER.trace("{} - Resending {}: {}", id, request, error);
        resendRequest(error, request, sender, connection, future);
      }
    }
  }
73569
def send_request(self, http_request):
        
        self.request_object = http_request
        self.build_socket()
        self.build_request()
        try:
            self.sock.send(self.request)
        except socket.error as err:
            raise errors.TestError(
                'We were unable to send the request to the socket',
                {
                    'msg': err,
                    'function': 'http.HttpUA.send_request'
                })  			
        finally:
            self.get_response()
1170041
def _send_loop(self):
        """"""
        while True:
            message, response_queue = self._send_queue.get()
            if message is self.STOP:
                break
            try:
                self._response_queues.put(response_queue)
                self._socket.send(message)
            except Exception:  # pylint:disable=broad-except
                log.exception("Exception sending message %s", message)
768737
def send(self, request: Request, stack: Stack) -> Coroutine:
        

        if stack.annotation not in self.PATTERNS:
            if not self.accept(stack):
                raise UnacceptableStack('Cannot accept stack {}'.format(stack))

        func = getattr(self, '_send_' + stack.annotation)
        return func(request, stack)
540197
function send(httpMethod, path, req) {
    req = req || {};
    httpMethod = httpMethod.toUpperCase();

    var deferred = Q.defer();
    var url = baseUrl + path;
    var data = req.data || {};          // separate out data from request
    delete req.data;

    var isAdmin = req.caller && req.caller.role === 'admin';
    delete req.caller;

    var id = req._id || data._id;       // get id from request or data
    if (req._id) { delete req._id; }    // delete id from request so no dupe

    var session = cls.getNamespace('appSession');
    var caller = session && session.active && session.get('caller');
    if (caller && !isAdmin) {
        _.extend(req, {                 // onBehalfOf used by API to know who is the caller
            onBehalfOfType: caller.type,
            onBehalfOfId:   caller._id + '',
            onBehalfOfRole: caller.role,
            onBehalfOfName: caller.name
        });
    }

    _.each(req, function (val, key) {
        if (!_.isString(val)) { req[key] = JSON.stringify(val); }
    });

    // replace the ID portion of the URL
    url = id ?
        url.replace('{_id}', id + '') :
        url.replace('/{_id}', '');

    var reqConfig = {
        headers:    headers,
        url:        url,
        method:     httpMethod,
        qs:         _.isEmpty(req) ? undefined : req,
        json:       _.isEmpty(data) ? true : data
    };

    // if baseUrl not there yet, wait for 100 seconds until it is (i.e. during system startup)
    if (!baseUrl) {
        setTimeout(function () {
            makeRequest(reqConfig, deferred);
        }, 100);
    }
    else {
        makeRequest(reqConfig, deferred);
    }

    return deferred.promise;
}
519599
def send(self, timeout=None):
        """"""
        if self.sigint_event and is_main_thread():
            with ReplacedSigIntHandler(self.sigint_handler):
                return self._send(timeout)
        else:
            return self._send(timeout)
680310
public static void send(UnitRequest unitRequest, NotifyHandler handler) {
        unitRequest.getContext().setRouted(true);
        singleton.send(unitRequest, handler);
    }
1086936
def send_request(self, request):
        """"""
        # throttle the number of requests to each host
        self.aggregate.wait_for_host(self.urlparts[1])
        kwargs = self.get_request_kwargs()
        kwargs["allow_redirects"] = False
        self._send_request(request, **kwargs)
243086
def _sendRequest(self, tReq):
        """"""
        try:
            tReq.sent = True
            self.proto.sendString(tReq.data)
        except Exception as e:
            log.exception('%r: Failed to send request %r', self, tReq)
            del self.requests[tReq.id]
            tReq.d.errback(e)
        else:
            if not tReq.expect:
                # Once we've sent a request for which we don't expect a reply,
                # we're done, remove it from requests, and fire the deferred
                # with 'None', since there is no reply to be expected
                del self.requests[tReq.id]
                tReq.d.callback(None)
173129
function send() {
  'use strict';
  var req = new XMLHttpRequest(),
    specs = jsApiReporter.specs(),
    payload;

  if (specs.length) {
    specs.push(logs);
  }
  payload = JSON.stringify(specs);

  req.open('post', 'http://localhost:' + port + '/put', true);
  req.onload = function () {
    if (this.responseText === 'kill') {
      chrome.app.window.current().close();
    }
  };
  req.send(payload);
}
579726
def send(self, msg):
        """"""
        if self._req_ctx is not None:
            self._send(msg)
        else:
            self._send_queue.put(msg)
            self._event.set()
83499
def _send_request(self, method, url, *args, **kwargs):
        
        action = LOG_JWS_REQUEST(url=url)
        with action.context():
            headers = kwargs.setdefault('headers', Headers())
            headers.setRawHeaders(b'user-agent', [self._user_agent])
            kwargs.setdefault('timeout', self.timeout)
            return (
                DeferredContext(
                    self._treq.request(method, url, *args, **kwargs))
                .addCallback(
                    tap(lambda r: action.add_success_fields(
                        code=r.code,
                        content_type=r.headers.getRawHeaders(
                            b'content-type', [None])[0])))
                .addActionFinish())
1151746
def send(self, request):
        ''''''
        return self.session.send(request(self.url, self.auth))
1140189
def send_request(self, request, callback=None, timeout=None, no_response=False):  # pragma: no cover
        
        if callback is not None:
            thread = threading.Thread(target=self._thread_body, args=(request, callback))
            thread.start()
        else:
            self.protocol.send_message(request)
            if no_response:
                return
            try:
                response = self.queue.get(block=True, timeout=timeout)
            except Empty:
                #if timeout is set
                response = None
            return response
1187393
def send_request(id, method, params)
      data = MessagePack.dump([0, id, method, params]).bytes
      ws.send(data)
    rescue => exc
      warn exc
      abort exc
    end
306391
def request(uri, method, data = nil, type = :write, request_options = {})
      exceptions = []

      connect_timeout = @connect_timeout
      send_timeout = if type == :search
        @search_timeout
      elsif type == :batch
        type = :write
        @batch_timeout
      else
        @send_timeout
      end
      receive_timeout = type == :search ? @search_timeout : @receive_timeout

      thread_local_hosts(type != :write).each_with_index do |host, i|
        connect_timeout += 2 if i == 2
        send_timeout += 10 if i == 2
        receive_timeout += 10 if i == 2

        thread_index_key = type != :write ? "algolia_search_host_index_#{application_id}" : "algolia_host_index_#{application_id}"
        Thread.current[thread_index_key] = host[:index]
        host[:last_call] = Time.now.to_i

        host[:session].connect_timeout = connect_timeout
        host[:session].send_timeout = send_timeout
        host[:session].receive_timeout = receive_timeout
        begin
          return perform_request(host[:session], host[:base_url] + uri, method, data, request_options)
        rescue AlgoliaProtocolError => e
          raise if e.code / 100 == 4
          exceptions << e
        rescue => e
          exceptions << e
        end
        host[:session].reset_all
      end
      raise AlgoliaProtocolError.new(0, "Cannot reach any host: #{exceptions.map { |e| e.to_s }.join(', ')}")
    end