MCPcopy Index your code
hub / github.com/apache/dubbo-python2 / _parse_response

Method _parse_response

dubbo/connection/connections.py:189–217  ·  view source on GitHub ↗

对dubbo的响应数据进行解析 :param invoke_id: :param body: :return:

(self, invoke_id, body)

Source from the content-addressed store, hash-verified

187 return body_length, 3, invoke_id
188
189 def _parse_response(self, invoke_id, body):
190 """
191 对dubbo的响应数据进行解析
192 :param invoke_id:
193 :param body:
194 :return:
195 """
196 # invoke_id为None则意味着这是心跳的数据体,无需处理
197 if invoke_id is None:
198 return
199
200 try:
201 res = Response(body)
202 flag = res.read_int()
203 if flag == 2: # 响应的值为NULL
204 self.results[invoke_id] = None
205 elif flag == 1: # 正常的响应值
206 result = res.read_next()
207 self.results[invoke_id] = result
208 elif flag == 0: # 异常的响应值
209 self.results[invoke_id] = self._parse_error(res)
210 else:
211 raise DubboResponseException("Unknown result flag, expect '0' '1' '2', get " + flag)
212 except Exception as e:
213 logger.exception(e)
214 self.results[invoke_id] = e
215 finally:
216 self.conn_events[invoke_id].set() # 唤醒请求线程
217 logger.debug('Event set, invoked_id={}'.format(invoke_id))
218
219 @staticmethod
220 def _parse_error(res):

Callers 1

_callbackMethod · 0.95

Calls 6

read_intMethod · 0.95
read_nextMethod · 0.95
_parse_errorMethod · 0.95
ResponseClass · 0.90
formatMethod · 0.80

Tested by

no test coverage detected