本文整理匯總了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