From b2ccb3682e1efa6924c4434ad7eaf2c2861c9ae0 Mon Sep 17 00:00:00 2001 From: Antoine Millet Date: Thu, 27 Jan 2011 17:22:09 +0100 Subject: [PATCH] Added feature to embed data on asynchronous calls. --- sjrpc/core/rpcconnection.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sjrpc/core/rpcconnection.py b/sjrpc/core/rpcconnection.py index de1d35c..62435fd 100644 --- a/sjrpc/core/rpcconnection.py +++ b/sjrpc/core/rpcconnection.py @@ -266,11 +266,18 @@ class RpcConnection(object): :param \*\*kwargs: the keyword arguments for the call :return: the message id of the call ''' - + + # Extract _data from argument: + if '_data' in kwargs: + data = kwargs['_data'] + del kwargs['_data'] + else: + data = None + # Send the call to the peer: msg_id = self._send_call(method_name, *args, **kwargs) - self._calls[msg_id] = {'async': True} + self._calls[msg_id] = {'async': True, 'data': data} return msg_id @@ -323,6 +330,7 @@ class RpcConnection(object): else: # Else, it's an asynchonous call, so, we need to notify # manager that the response has been received: + message['data'] = call['data'] self._manager.signal_arrival(message) # Message will be deleted from the call list by the -- GitLab