當前位置: 首頁>>代碼示例>>Python>>正文


Python exceptions.IncompleteReadError方法代碼示例

本文整理匯總了Python中botocore.exceptions.IncompleteReadError方法的典型用法代碼示例。如果您正苦於以下問題:Python exceptions.IncompleteReadError方法的具體用法?Python exceptions.IncompleteReadError怎麽用?Python exceptions.IncompleteReadError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在botocore.exceptions的用法示例。


在下文中一共展示了exceptions.IncompleteReadError方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _get_object

# 需要導入模塊: from botocore import exceptions [as 別名]
# 或者: from botocore.exceptions import IncompleteReadError [as 別名]
def _get_object(self, bucket, key, filename, extra_args, callback):
        # precondition: num_download_attempts > 0
        max_attempts = self._config.num_download_attempts
        last_exception = None
        for i in range(max_attempts):
            try:
                return self._do_get_object(bucket, key, filename,
                                           extra_args, callback)
            except (socket.timeout, socket.error,
                    ReadTimeoutError, IncompleteReadError) as e:
                # TODO: we need a way to reset the callback if the
                # download failed.
                logger.debug("Retrying exception caught (%s), "
                             "retrying request, (attempt %s / %s)", e, i,
                             max_attempts, exc_info=True)
                last_exception = e
                continue
        raise RetriesExceededError(last_exception) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:20,代碼來源:__init__.py

示例2: _verify_content_length

# 需要導入模塊: from botocore import exceptions [as 別名]
# 或者: from botocore.exceptions import IncompleteReadError [as 別名]
def _verify_content_length(self):
        # See: https://github.com/kennethreitz/requests/issues/1855
        # Basically, our http library doesn't do this for us, so we have
        # to do this ourself.
        if self._self_content_length is not None and \
                self._self_amount_read != int(self._self_content_length):
            raise IncompleteReadError(
                actual_bytes=self._self_amount_read,
                expected_bytes=int(self._self_content_length)) 
開發者ID:aio-libs,項目名稱:aiobotocore,代碼行數:11,代碼來源:response.py

示例3: test_streaming_body_with_invalid_length

# 需要導入模塊: from botocore import exceptions [as 別名]
# 或者: from botocore.exceptions import IncompleteReadError [as 別名]
def test_streaming_body_with_invalid_length():
    body = AsyncBytesIO(b'123456789')
    stream = response.StreamingBody(body, content_length=10)
    with pytest.raises(IncompleteReadError):
        assert await stream.read(9) == b'123456789'
        # The next read will have nothing returned and raise
        # an IncompleteReadError because we were expectd 10 bytes, not 9.
        await stream.read() 
開發者ID:aio-libs,項目名稱:aiobotocore,代碼行數:10,代碼來源:test_response.py

示例4: test_streaming_body_with_single_read

# 需要導入模塊: from botocore import exceptions [as 別名]
# 或者: from botocore.exceptions import IncompleteReadError [as 別名]
def test_streaming_body_with_single_read():
    body = AsyncBytesIO(b'123456789')
    stream = response.StreamingBody(body, content_length=10)
    with pytest.raises(IncompleteReadError):
        await stream.read() 
開發者ID:aio-libs,項目名稱:aiobotocore,代碼行數:7,代碼來源:test_response.py

示例5: _verify_content_length

# 需要導入模塊: from botocore import exceptions [as 別名]
# 或者: from botocore.exceptions import IncompleteReadError [as 別名]
def _verify_content_length(self):
        # See: https://github.com/kennethreitz/requests/issues/1855
        # Basically, our http library doesn't do this for us, so we have
        # to do this ourself.
        if self._content_length is not None and \
                self._amount_read != int(self._content_length):
            raise IncompleteReadError(
                actual_bytes=self._amount_read,
                expected_bytes=int(self._content_length)) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:11,代碼來源:response.py

示例6: _download_range

# 需要導入模塊: from botocore import exceptions [as 別名]
# 或者: from botocore.exceptions import IncompleteReadError [as 別名]
def _download_range(self, bucket, key, filename,
                        part_size, num_parts, callback, part_index):
        try:
            range_param = self._calculate_range_param(
                part_size, part_index, num_parts)

            max_attempts = self._config.num_download_attempts
            last_exception = None
            for i in range(max_attempts):
                try:
                    logger.debug("Making get_object call.")
                    response = self._client.get_object(
                        Bucket=bucket, Key=key, Range=range_param)
                    streaming_body = StreamReaderProgress(
                        response['Body'], callback)
                    buffer_size = 1024 * 16
                    current_index = part_size * part_index
                    for chunk in iter(lambda: streaming_body.read(buffer_size),
                                      b''):
                        self._ioqueue.put((current_index, chunk))
                        current_index += len(chunk)
                    return
                except (socket.timeout, socket.error,
                        ReadTimeoutError, IncompleteReadError) as e:
                    logger.debug("Retrying exception caught (%s), "
                                 "retrying request, (attempt %s / %s)", e, i,
                                 max_attempts, exc_info=True)
                    last_exception = e
                    continue
            raise RetriesExceededError(last_exception)
        finally:
            logger.debug("EXITING _download_range for part: %s", part_index) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:34,代碼來源:__init__.py


注:本文中的botocore.exceptions.IncompleteReadError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。