aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api
diff options
context:
space:
mode:
authorVratko Polak <vrpolak@cisco.com>2019-09-06 15:20:07 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2019-09-30 15:19:29 +0000
commite6b29a9df5df39204f6235256fc07a703c2d0336 (patch)
treea011c41e2e67ce9250c4fb274314674893aab2be /src/vpp-api
parent45a02523b13e7d211b5350294dd934c66af10c5d (diff)
papi: let async calls return context
Callback receives "reply" messages containing context, but previously there was no easy way to get the automatically generated context value of the originally sent "command" message. With this, the caller can store the contexts, so the callback knows which command got replied to. Type: feature Change-Id: I58ca812d20b03916f74096c396126710115a747c Signed-off-by: Vratko Polak <vrpolak@cisco.com> (cherry picked from commit 2f6e0c6002f732b7f938a0f770f19c9dec9269f1)
Diffstat (limited to 'src/vpp-api')
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_papi.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/vpp-api/python/vpp_papi/vpp_papi.py b/src/vpp-api/python/vpp_papi/vpp_papi.py
index b3f2a156939..84a3e515b89 100644
--- a/src/vpp-api/python/vpp_papi/vpp_papi.py
+++ b/src/vpp-api/python/vpp_papi/vpp_papi.py
@@ -669,13 +669,17 @@ class VPPApiClient(object):
return rl
def _call_vpp_async(self, i, msg, **kwargs):
- """Given a message, send the message and await a reply.
+ """Given a message, send the message and return the context.
msgdef - the message packing definition
i - the message type index
context - context number - chosen at random if not
supplied.
The remainder of the kwargs are the arguments to the API call.
+
+ The reply message(s) will be delivered later to the registered callback.
+ The returned context will help with assigning which call
+ the reply belongs to.
"""
if 'context' not in kwargs:
context = self.get_context()
@@ -691,6 +695,7 @@ class VPPApiClient(object):
b = msg.pack(kwargs)
self.transport.write(b)
+ return context
def register_event_callback(self, callback):
"""Register a callback for async messages.