本文整理汇总了Python中botocore.vendored.requests.exceptions.ConnectionError方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.ConnectionError方法的具体用法?Python exceptions.ConnectionError怎么用?Python exceptions.ConnectionError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类botocore.vendored.requests.exceptions
的用法示例。
在下文中一共展示了exceptions.ConnectionError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete
# 需要导入模块: from botocore.vendored.requests import exceptions [as 别名]
# 或者: from botocore.vendored.requests.exceptions import ConnectionError [as 别名]
def delete(self):
# delete table
try:
return self.table.delete()
except ClientError:
raise ClientException('Cannot do operations on a non-existent table')
except ConnectionError:
raise ConnectionException('Connection refused')
示例2: _get_response
# 需要导入模块: from botocore.vendored.requests import exceptions [as 别名]
# 或者: from botocore.vendored.requests.exceptions import ConnectionError [as 别名]
def _get_response(self, request, operation_model, attempts):
# This will return a tuple of (success_response, exception)
# and success_response is itself a tuple of
# (http_response, parsed_dict).
# If an exception occurs then the success_response is None.
# If no exception occurs then exception is None.
try:
logger.debug("Sending http request: %s", request)
http_response = self.http_session.send(
request, verify=self.verify,
stream=operation_model.has_streaming_output,
proxies=self.proxies, timeout=self.timeout)
except ConnectionError as e:
# For a connection error, if it looks like it's a DNS
# lookup issue, 99% of the time this is due to a misconfigured
# region/endpoint so we'll raise a more specific error message
# to help users.
logger.debug("ConnectionError received when sending HTTP request.",
exc_info=True)
if self._looks_like_dns_error(e):
endpoint_url = e.request.url
better_exception = EndpointConnectionError(
endpoint_url=endpoint_url, error=e)
return (None, better_exception)
elif self._looks_like_bad_status_line(e):
better_exception = ConnectionClosedError(
endpoint_url=e.request.url, request=e.request)
return (None, better_exception)
else:
return (None, e)
except Exception as e:
logger.debug("Exception received when sending HTTP request.",
exc_info=True)
return (None, e)
# This returns the http_response and the parsed_data.
response_dict = convert_to_response_dict(http_response,
operation_model)
parser = self._response_parser_factory.create_parser(
operation_model.metadata['protocol'])
parsed_response = parser.parse(
response_dict, operation_model.output_shape)
return (http_response, parsed_response), None