MCPcopy Create free account
hub / github.com/FDio/vpp / _call_vpp

Method _call_vpp

src/vpp-api/python/vpp_papi/vpp_papi.py:790–880  ·  view source on GitHub ↗

Given a message, send the message and await a reply. msgdef - the message packing definition i - the message type index multipart - True if the message returns multiple messages in return. context - context number - chosen at random if not supplied.

(self, i, msgdef, service, **kwargs)

Source from the content-addressed store, hash-verified

788 return _def[2]
789
790 def _call_vpp(self, i, msgdef, service, **kwargs):
791 """Given a message, send the message and await a reply.
792
793 msgdef - the message packing definition
794 i - the message type index
795 multipart - True if the message returns multiple
796 messages in return.
797 context - context number - chosen at random if not
798 supplied.
799 The remainder of the kwargs are the arguments to the API call.
800
801 The return value is the message or message array containing
802 the response. It will raise an IOError exception if there was
803 no response within the timeout window.
804 """
805 ts = time.time()
806 if "context" not in kwargs:
807 context = self.get_context()
808 kwargs["context"] = context
809 else:
810 context = kwargs["context"]
811 kwargs["_vl_msg_id"] = i
812
813 no_type_conversion = kwargs.pop("_no_type_conversion", False)
814 timeout = kwargs.pop("_timeout", None)
815
816 try:
817 if self.transport.socket_index:
818 kwargs["client_index"] = self.transport.socket_index
819 except AttributeError:
820 pass
821 self.validate_args(msgdef, kwargs)
822
823 s = "Calling {}({})".format(
824 msgdef.name, ",".join(["{!r}:{!r}".format(k, v) for k, v in kwargs.items()])
825 )
826 self.logger.debug(s)
827
828 b = msgdef.pack(kwargs)
829 self.transport.suspend()
830
831 self.transport.write(b)
832
833 msgreply = service["reply"]
834 stream = True if "stream" in service else False
835 if stream:
836 if "stream_msg" in service:
837 # New service['reply'] = _reply and service['stream_message'] = _details
838 stream_message = service["stream_msg"]
839 modern = True
840 else:
841 # Old service['reply'] = _details
842 stream_message = msgreply
843 msgreply = "control_ping_reply"
844 modern = False
845 # Send a ping after the request - we use its response
846 # to detect that we have seen all results.
847 self._control_ping(context)

Callers 1

fMethod · 0.95

Calls 13

validate_argsMethod · 0.95
_control_pingMethod · 0.95
read_blockingMethod · 0.95
_add_statMethod · 0.95
printFunction · 0.85
get_contextMethod · 0.80
formatMethod · 0.80
suspendMethod · 0.80
appendMethod · 0.80
resumeMethod · 0.80
VPPIOErrorClass · 0.70
packMethod · 0.45

Tested by

no test coverage detected