當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。