diff --git a/sjrpc/core/connectionmanagers.py b/sjrpc/core/connectionmanagers.py index e6ced6478c2739b08637d0a70c5c13f7d0c913c1..2aeef7c4091a7647257ab6737c1a93ce51d69002 100644 --- a/sjrpc/core/connectionmanagers.py +++ b/sjrpc/core/connectionmanagers.py @@ -92,6 +92,19 @@ class ConnectionManager(object): if not already_completed: waiter['event'].wait(timeout=timeout) + # Clean the call list on each attached RpcConnection + for connection in self.all_connections(): + connection.clean_all_calls(msg_id_set) + + # Get the messages: + messages = [] + + for msg_id, msg in self._received_msg.items(): + if msg_id in msg_id_set: + messages.append(msg) + del self._received_msg[msg_id] + waiter['responses'] = tuple(messages) + messages = waiter['responses'] del self._wait_groups[msg_id_set] @@ -130,19 +143,6 @@ class ConnectionManager(object): or not waiter['wait_all'] and not recv_msg.isdisjoint(waitset)) if is_ok: - # Clean the call list on each attached RpcConnection - for connection in self.all_connections(): - connection.clean_all_calls(waitset) - - # Get the messages: - messages = [] - - for msg_id, msg in self._received_msg.items(): - if msg_id in waitset: - messages.append(msg) - del self._received_msg[msg_id] - waiter['responses'] = tuple(messages) - # Unlock the event: waiter['event'].set()