def send_request(self, method_name, is_notification, params):
"""Issue the HTTP request to the server and return the method result (if not a notification)"""
request_body = self.serialize(method_name, params, is_notification)
try:
response = self.request(data=request_body)
except requests.RequestException as requests_exception:
raise TransportError('Error calling method %r' % method_name, requests_exception)
if response.status_code != requests.codes.ok:
raise TransportError(response.status_code)
if not is_notification:
try:
parsed = response.json()
except ValueError as value_error:
raise TransportError('Cannot deserialize response body', value_error)
return self.parse_result(parsed)
评论列表
文章目录