本文整理汇总了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.")
示例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
示例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
示例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