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


Python exceptions.ConnectionError方法代码示例

本文整理汇总了Python中botocore.exceptions.ConnectionError方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.ConnectionError方法的具体用法?Python exceptions.ConnectionError怎么用?Python exceptions.ConnectionError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在botocore.exceptions的用法示例。


在下文中一共展示了exceptions.ConnectionError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: find_usage

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import ConnectionError [as 别名]
def find_usage(self):
        """
        Determine the current usage for each limit of this service,
        and update corresponding Limit via
        :py:meth:`~.AwsLimit._add_current_usage`.
        """
        logger.debug("Checking usage for service %s", self.service_name)
        self.connect()
        for lim in self.limits.values():
            lim._reset_usage()
        try:
            self._find_usage_filesystems()
        except (ConnectionError, ClientError) as ex:
            logger.warning(
                'Caught exception when trying to use EFS ('
                'perhaps the EFS service is not available in this '
                'region?): %s', ex
            )
        self._have_usage = True
        logger.debug("Done checking usage.") 
开发者ID:jantman,项目名称:awslimitchecker,代码行数:22,代码来源:efs.py

示例2: test_find_usage_no_endpoint

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import ConnectionError [as 别名]
def test_find_usage_no_endpoint(self):
        exc = ConnectionError(
            error='foo'
        )
        mock_conn = Mock()
        with patch('%s.connect' % pb) as mock_connect:
            with patch('%s.paginate_dict' % pbm) as mock_paginate:
                mock_paginate.side_effect = exc
                cls = _EfsService(21, 43, {}, None)
                cls.conn = mock_conn
                assert cls._have_usage is False
                cls.find_usage()
        assert cls._have_usage is True
        assert mock_connect.mock_calls == [call()]
        assert mock_paginate.mock_calls == [
            call(
                mock_conn.describe_file_systems,
                alc_marker_path=['NextMarker'],
                alc_data_path=['FileSystems'],
                alc_marker_param='Marker'
            )
        ]
        assert len(cls.limits) == 1
        usage = cls.limits['File systems'].get_current_usage()
        assert len(usage) == 0 
开发者ID:jantman,项目名称:awslimitchecker,代码行数:27,代码来源:test_efs.py

示例3: _refresh_current_endpoints

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import ConnectionError [as 别名]
def _refresh_current_endpoints(self, **kwargs):
        cache_key = self._create_cache_key(**kwargs)
        try:
            response = self._describe_endpoints(**kwargs)
            endpoints = self._parse_endpoints(response)
            self._cache[cache_key] = endpoints
            self._failed_attempts.pop(cache_key, None)
            return endpoints
        except (ConnectionError, HTTPClientError):
            self._failed_attempts[cache_key] = self._time() + 60
            return None 
开发者ID:QData,项目名称:deepWordBug,代码行数:13,代码来源:discovery.py

示例4: run

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import ConnectionError [as 别名]
def run(self) -> None:
        """
        Watch for new logs and pass each log entry to the "consumer" function.
        """

        # Track the last timestamp we see.  When we fetch_stream() again on the
        # next iteration, we'll start from that timestamp onwards to avoid
        # fetching every single page again.  The last event or two will be
        # still be in the response, but our de-duping will ignore those.
        last_timestamp = None

        # Keep track of what log entries we've consumed so that we suppress
        # duplicates.  Duplicates will arise in our stream due to the way we
        # watch for new entries.
        consumed = set()    # type: MutableSet

        # How many successful vs failed fetch_stream calls.  If we consistently see
        # failures but we never see a successful attempt, we should raise an exception
        # and stop.
        success_count = 0
        failure_count = 0

        while not self.stopped.wait(0.2):
            try:
                for entry in fetch_stream(self.stream, start_time = last_timestamp):
                    if entry["eventId"] not in consumed:
                        consumed.add(entry["eventId"])

                        last_timestamp = entry["timestamp"]

                        self.consumer(entry)
            except (ClientError, BotocoreConnectionError):
                failure_count += 1
                if failure_count > MAX_FAILURES and not success_count:
                    raise
            else:
                success_count += 1 
开发者ID:nextstrain,项目名称:cli,代码行数:39,代码来源:logs.py


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