本文整理匯總了Python中boto3.exceptions.RetriesExceededError方法的典型用法代碼示例。如果您正苦於以下問題:Python exceptions.RetriesExceededError方法的具體用法?Python exceptions.RetriesExceededError怎麽用?Python exceptions.RetriesExceededError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類boto3.exceptions
的用法示例。
在下文中一共展示了exceptions.RetriesExceededError方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: download_file
# 需要導入模塊: from boto3 import exceptions [as 別名]
# 或者: from boto3.exceptions import RetriesExceededError [as 別名]
def download_file(self, bucket, key, filename, extra_args=None,
callback=None):
"""Download an S3 object to a file.
Variants have also been injected into S3 client, Bucket and Object.
You don't have to use S3Transfer.download_file() directly.
"""
if not isinstance(filename, six.string_types):
raise ValueError('Filename must be a string')
subscribers = self._get_subscribers(callback)
future = self._manager.download(
bucket, key, filename, extra_args, subscribers)
try:
future.result()
# This is for backwards compatibility where when retries are
# exceeded we need to throw the same error from boto3 instead of
# s3transfer's built in RetriesExceededError as current users are
# catching the boto3 one instead of the s3transfer exception to do
# their own retries.
except S3TransferRetriesExceededError as e:
raise RetriesExceededError(e.last_exception)
示例2: _native_download_file
# 需要導入模塊: from boto3 import exceptions [as 別名]
# 或者: from boto3.exceptions import RetriesExceededError [as 別名]
def _native_download_file(meta, full_dst_file_name, max_concurrency):
logger = getLogger(__name__)
try:
akey = SnowflakeS3Util._get_s3_object(meta, meta['src_file_name'])
akey.download_file(
full_dst_file_name,
Callback=meta['get_callback'](
meta['src_file_name'],
meta['src_file_size'],
output_stream=meta['get_callback_output_stream'],
show_progress_bar=meta['show_progress_bar']) if
meta['get_callback'] else None,
Config=TransferConfig(
multipart_threshold=SnowflakeS3Util.DATA_SIZE_THRESHOLD,
max_concurrency=max_concurrency,
num_download_attempts=10,
)
)
meta['result_status'] = ResultStatus.DOWNLOADED
except botocore.exceptions.ClientError as err:
if err.response['Error']['Code'] == EXPIRED_TOKEN:
meta['result_status'] = ResultStatus.RENEW_TOKEN
else:
logger.debug(
"Failed to download a file: %s, err: %s",
full_dst_file_name, err, exc_info=True)
raise err
except RetriesExceededError as err:
meta['result_status'] = ResultStatus.NEED_RETRY
meta['last_error'] = err
except OpenSSL.SSL.SysCallError as err:
meta['last_error'] = err
if err.args[0] == ERRORNO_WSAECONNABORTED:
# connection was disconnected by S3
# because of too many connections. retry with
# less concurrency to mitigate it
meta[
'result_status'] = ResultStatus.NEED_RETRY_WITH_LOWER_CONCURRENCY
else:
meta['result_status'] = ResultStatus.NEED_RETRY
示例3: download_file
# 需要導入模塊: from boto3 import exceptions [as 別名]
# 或者: from boto3.exceptions import RetriesExceededError [as 別名]
def download_file(self, bucket, key, filename, extra_args=None,
callback=None):
"""Download an S3 object to a file.
Variants have also been injected into S3 client, Bucket and Object.
You don't have to use S3Transfer.download_file() directly.
.. seealso::
:py:meth:`S3.Client.download_file`
:py:meth:`S3.Client.download_fileobj`
"""
if not isinstance(filename, six.string_types):
raise ValueError('Filename must be a string')
subscribers = self._get_subscribers(callback)
future = self._manager.download(
bucket, key, filename, extra_args, subscribers)
try:
future.result()
# This is for backwards compatibility where when retries are
# exceeded we need to throw the same error from boto3 instead of
# s3transfer's built in RetriesExceededError as current users are
# catching the boto3 one instead of the s3transfer exception to do
# their own retries.
except S3TransferRetriesExceededError as e:
raise RetriesExceededError(e.last_exception)