From 64bc612d4ce682fdd4a6e1c8a47b7538f200b24f Mon Sep 17 00:00:00 2001 From: Wojciech Dec Date: Mon, 12 Dec 2016 11:32:25 +0100 Subject: Fix for PAPI async call registration Introduce async API call registration Change-Id: Iccc89eca1b6e7dcce96a8e7bc5da80d9abc363fc Signed-off-by: Wojciech Dec --- vpp-api/python/vpp_papi/vpp_papi.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'vpp-api/python/vpp_papi') diff --git a/vpp-api/python/vpp_papi/vpp_papi.py b/vpp-api/python/vpp_papi/vpp_papi.py index 27d4315aae4..312aa335572 100644 --- a/vpp-api/python/vpp_papi/vpp_papi.py +++ b/vpp-api/python/vpp_papi/vpp_papi.py @@ -241,10 +241,13 @@ class VPP(): def add_type(self, name, typedef): self.add_message('vl_api_' + name + '_t', typedef) - def make_function(self, i, msgdef, multipart): - return lambda **kwargs: (self._call_vpp(i, msgdef, multipart, **kwargs)) + def make_function(self, i, msgdef, multipart, async): + if (async): + return lambda **kwargs: (self._call_vpp_async(i, msgdef, multipart, **kwargs)) + else: + return lambda **kwargs: (self._call_vpp(i, msgdef, multipart, **kwargs)) - def _register_functions(self): + def _register_functions(self, async=False): self.id_names = [None] * (self.vpp_dictionary_maxid + 1) self.id_msgdef = [None] * (self.vpp_dictionary_maxid + 1) for name, msgdef in self.messages.iteritems(): @@ -257,7 +260,7 @@ class VPP(): self.id_msgdef[i] = msgdef self.id_names[i] = name multipart = True if name.find('_dump') > 0 else False - setattr(self, name, self.make_function(i, msgdef, multipart)) + setattr(self, name, self.make_function(i, msgdef, multipart, async)) def _write (self, buf): if not self.connected: @@ -289,7 +292,7 @@ class VPP(): self.connected = True self._load_dictionary() - self._register_functions() + self._register_functions(async=async) # Initialise control ping self.control_ping_index = self.vpp_dictionary['control_ping']['id'] -- cgit 1.2.3-korg