Convert a model run request from the buffer into a message in a RabbitMQ
    queue.

    Parameters
    ----------
    request : dict
        Buffer entry containing 'connector' and 'request' field
349672
def handle_request(request):
    
    connector = request['connector']
    hostname = connector['host']
    port = connector['port']
    virtual_host = connector['virtualHost']
    queue = connector['queue']
    user = connector['user']
    password = connector['password']
    # Establish connection with RabbitMQ server
    logging.info('Connect : [HOST=' + hostname + ', QUEUE=' + queue + ']')
    done = False
    attempts = 0
    while not done and attempts < 100:
        try:
            credentials = pika.PlainCredentials(user, password)
            con = pika.BlockingConnection(pika.ConnectionParameters(
                host=hostname,
                port=port,
                virtual_host=virtual_host,
                credentials=credentials
            ))
            channel = con.channel()
            channel.queue_declare(queue=queue, durable=True)
            req = request['request']
            logging.info('Run : [EXPERIMENT=' + req['experiment_id'] + ', RUN=' + req['run_id'] + ']')
            channel.basic_publish(
                exchange='',
                routing_key=queue,
                body=json.dumps(req),
                properties=pika.BasicProperties(
                    delivery_mode = 2, # make message persistent
                )
            )
            con.close()
            done = True
        except pika.exceptions.ConnectionClosed as ex:
            attempts += 1
            logging.exception(ex)
437508
def request(self, *args, **kwargs):
        
        func = partial(super().request, *args, **kwargs)
        return self.loop.run_in_executor(self.thread_pool, func)
347666
def _create_request(self, messages):
        

        msg = ','.join(messages)
        request = '{{"request":"sender data","data":[{msg}]}}'.format(msg=msg)
        request = request.encode("utf-8")
        logger.debug('Request: %s', request)

        return request
1335192
def encode_request(name, expected, updated):
    
    client_message = ClientMessage(payload_size=calculate_size(name, expected, updated))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_long(expected)
    client_message.append_long(updated)
    client_message.update_frame_length()
    return client_message
1314649
def parse_request(self, request, parameters=None, fake_method=None):
        '''
        
        '''
        return (request.method,
                request.url,
                request.headers,
                request.form.copy())
594467
def translate_request(request):
    
    class AwaitablePayload(object):
        def __init__(self, payload):
            self.payload = payload or b''

        async def read(self, length=None):
            if length is None:
                r = self.payload
                self.payload = b''
            else:
                r = self.payload[:length]
                self.payload = self.payload[length:]
            return r

    uri_parts = urlsplit(request.url)
    environ = {
        'wsgi.input': AwaitablePayload(request.body),
        'wsgi.errors': sys.stderr,
        'wsgi.version': (1, 0),
        'wsgi.async': True,
        'wsgi.multithread': False,
        'wsgi.multiprocess': False,
        'wsgi.run_once': False,
        'SERVER_SOFTWARE': 'sanic',
        'REQUEST_METHOD': request.method,
        'QUERY_STRING': uri_parts.query or '',
        'RAW_URI': request.url,
        'SERVER_PROTOCOL': 'HTTP/' + request.version,
        'REMOTE_ADDR': '127.0.0.1',
        'REMOTE_PORT': '0',
        'SERVER_NAME': 'sanic',
        'SERVER_PORT': '0',
        'sanic.request': request
    }

    for hdr_name, hdr_value in request.headers.items():
        hdr_name = hdr_name.upper()
        if hdr_name == 'CONTENT-TYPE':
            environ['CONTENT_TYPE'] = hdr_value
            continue
        elif hdr_name == 'CONTENT-LENGTH':
            environ['CONTENT_LENGTH'] = hdr_value
            continue

        key = 'HTTP_%s' % hdr_name.replace('-', '_')
        if key in environ:
            hdr_value = '%s,%s' % (environ[key], hdr_value)

        environ[key] = hdr_value

    environ['wsgi.url_scheme'] = environ.get('HTTP_X_FORWARDED_PROTO', 'http')

    path_info = uri_parts.path

    environ['PATH_INFO'] = path_info
    environ['SCRIPT_NAME'] = ''

    return environ
96159
def read_request_line(self, request_line):
		

		request = self.__request_cls.parse_request_line(self, request_line)

		protocol_version = self.protocol_version()
		if protocol_version == '0.9':
			if request.method() != 'GET':
				raise Exception('HTTP/0.9 standard violation')
		elif protocol_version == '1.0' or protocol_version == '1.1':
			pass
		elif protocol_version == '2':
			pass
		else:
			raise RuntimeError('Unsupported HTTP-protocol')
284492
def build_request(self, input_data=None, api_data=None, aux_data=None, *args, **kwargs):
        
        if input_data is not None:
            self.client_data = input_data
        if api_data is not None:
            self.api_data = api_data
        if aux_data is not None:
            self.aux_data = aux_data

        self.request = RequestHolder()
        self.request.nonce = get_random_vector(EBConsts.FRESHNESS_NONCE_LEN)

        self.request.endpoint = self.get_endpoint()
        self.request.url = self.get_endpoint().get_url() + self.url_suffix

        self.request.configuration = self.config
        self.request.api_method = self.operation
        self.request.headers = {'X-Auth-Token': 'public'}

        # Result request body
        self.request.body = {
            'nonce': to_hex(self.request.nonce),
            'version': 1,
            'function': self.operation,
            'environment': self.env if self.env is not None else ENVIRONMENT_DEVELOPMENT,
        }

        if self.client_data is not None:
            self.request.body['client'] = self.client_data
        if self.api_data is not None:
            self.request.body['apidata'] = self.api_data
        if self.aux_data is not None:
            if isinstance(self.aux_data, dict):
                self.request.body = EBUtils.merge(self.request.body, self.aux_data)
            else:
                raise ValueError('Aux data has to be a dictionary')

        self.request = self.extend_request(self.request)
        return self.request
1182353
def __make_request_method(self, teststep_dict, entry_json):
        
        method = entry_json["request"].get("method")
        if not method:
            logging.exception("method missed in request.")
            sys.exit(1)

        teststep_dict["request"]["method"] = method
131567
def handleRequest(self, obj, socket, multi=False):
        '''
        
        '''
        while 1:
            try:
                msg = socket.recv_multipart(zmq.NOBLOCK)
                method = msg[0].decode()
                try:
                    args = pickle.loads(msg[1], **pickle_options)
                except ValueError as err:
                    self._logger.notice('Request %s failed. Caught %s %s' %
                                        (method, type(err), str(err)))
                    self._sendAnswer(socket, err)
                self._logger.debug("received request %s %s" %
                                   (method, str(args)))
                try:
                    res= getattr(obj, method).__call__(*args)
                except Exception as e:
                    self._logger.notice('Request %s %s failed. Caught %s %s' %
                                        (method, str(args), type(e), str(e)))
                    res= e
                self._sendAnswer(socket, res)
            except zmq.ZMQError:
                return
            except Exception as e:
                self._logger.error("Unknown error %s" % str(e))
            if not multi:
                break
1357114
def _parse_request_arguments(self, request):
    
    inference_addresses = request.args.get('inference_address').split(',')
    model_names = request.args.get('model_name').split(',')
    model_versions = request.args.get('model_version').split(',')
    model_signatures = request.args.get('model_signature').split(',')
    if len(model_names) != len(inference_addresses):
      raise common_utils.InvalidUserInputError('Every model should have a ' +
                                                'name and address.')
    return inference_addresses, model_names, model_versions, model_signatures
1374291
def _do_request(request):
    
    if request.request_type is RequestType.GET:
        return requests.get(request.url, headers=request.headers)
    if request.request_type is RequestType.POST:
        return requests.post(request.url, data=json.dumps(request.post_values), headers=request.headers)
    raise ValueError('Invalid request type {}'.format(request.request_type))
902903
def getAMFRequest(self, requests):
        
        envelope = remoting.Envelope(self.amf_version)

        if self.logger:
            self.logger.debug('AMF version: %s' % self.amf_version)

        for request in requests:
            service = request.service
            args = list(request.args)

            envelope[request.id] = remoting.Request(str(service), args)

        envelope.headers = self.headers

        return envelope
931480
def add_request(self, request):
        

        queue_item = QueueItem(request, Response(request.url))
        self.add(queue_item)
        return queue_item
469063
static void rcvRequestMsgs(CommsByteBuffer request, Conversation conversation, int requestNumber,
                               boolean allocatedFromBufferPool, boolean partOfExchange)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "rcvRequestMsgs",
                        new Object[]
                        {
                         request,
                         conversation,
                         "" + requestNumber,
                         "" + allocatedFromBufferPool
                        });

        short connectionObjectID = request.getShort(); // BIT16 ConnectionObjectId
        short consumerObjectID = request.getShort(); // BIT16 SyncConsumerSessionId
        int receivedBytes = request.getInt(); // BIT32 ReceivedBytes
        int requestedBytes = request.getInt(); // BIT32 RequestedBytes

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
        {
            SibTr.debug(tc, "connectionObjectID", connectionObjectID);
            SibTr.debug(tc, "consumerObjectID", consumerObjectID);
            SibTr.debug(tc, "receivedBytes", receivedBytes);
            SibTr.debug(tc, "requestedBytes", requestedBytes);
        }

        CATMainConsumer mainConsumer =
                        ((CATMainConsumer) ((ConversationState) conversation.getAttachment()).getObject(consumerObjectID));

        mainConsumer.requestMsgs(requestNumber, receivedBytes, requestedBytes);

        request.release(allocatedFromBufferPool);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "rcvRequestMsgs");
    }
252305
def _create_packet(self, request):
        

        data_len = struct.pack('<Q', len(request))
        packet = b'ZBXD\x01' + data_len + request

        def ord23(x):
            if not isinstance(x, int):
                return ord(x)
            else:
                return x

        logger.debug('Packet [str]: %s', packet)
        logger.debug('Packet [hex]: %s',
                     ':'.join(hex(ord23(x))[2:] for x in packet))
        return packet
1157906
private Message messageFromBuffer(ByteBuffer request) throws InternalException {
    if (request != null) {
      Message m;
      try {
        m = parser.createMessage(request);
        return m;
      }
      catch (AvpDataException e) {
        throw new InternalException("Failed to decode message.", e);
      }
    }
    return null;
  }