当前位置: 首页>>代码示例>>Python>>正文


Python exceptions.ConnectionError方法代码示例

本文整理汇总了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') 
开发者ID:gusibi,项目名称:dynamodb-py,代码行数:10,代码来源:table.py

示例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 
开发者ID:lordmuffin,项目名称:aws-cfn-plex,代码行数:44,代码来源:endpoint.py


注:本文中的botocore.vendored.requests.exceptions.ConnectionError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。