Skip to content

Commit

Permalink
[storage.blob] Remove aiohttp as dependency for storage.blob.aio (#24965
Browse files Browse the repository at this point in the history
)

* Don't import from aiohttp in blob.aio

* update changelog

* remove dead code

* changelog formatting

* add retries back in

* Catch correct exception

* Update sdk/storage/azure-storage-blob/CHANGELOG.md

* missing import

* catch azure.core exceptions

* Revert

* changelog typo

* changelog formatting

* more changelog

* merge main

Co-authored-by: Laurent Mazuel <laurent.mazuel@gmail.com>
  • Loading branch information
Steven Jin and lmazuel committed Jul 1, 2022
1 parent 6bea2f0 commit e40d3e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
3 changes: 3 additions & 0 deletions sdk/storage/azure-storage-blob/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
## 12.13.0 (Unreleased)

### Features Added

### Bugs Fixed
- Stable release of features from 12.13.0b1.
- Added support for deleting versions in `delete_blobs` by supplying `version_id`.
- Removed forced `aiohttp` import from storage async download. (#24965)

## 12.13.0b1 (2022-06-15)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from typing import AsyncIterator

import asyncio
from aiohttp import ClientPayloadError
from azure.core.exceptions import HttpResponseError, ServiceResponseError

from azure.core.exceptions import HttpResponseError, ServiceResponseError, IncompleteReadError

from .._shared.request_handlers import validate_and_format_range_headers
from .._shared.response_handlers import process_storage_error, parse_length_from_content_range
Expand Down Expand Up @@ -114,14 +114,15 @@ async def _download_chunk(self, chunk_start, chunk_end):
)
retry_active = False

except HttpResponseError as error:
process_storage_error(error)
except ClientPayloadError as error:
except IncompleteReadError as error:
retry_total -= 1
if retry_total <= 0:
raise ServiceResponseError(error, error=error)
await asyncio.sleep(1)

except HttpResponseError as error:
process_storage_error(error)

chunk_data = await process_content(response, offset[0], offset[1], self.encryption_options)


Expand Down Expand Up @@ -356,6 +357,12 @@ async def _initial_request(self):
self.size = self._file_size
retry_active = False

except IncompleteReadError as error:
retry_total -= 1
if retry_total <= 0:
raise ServiceResponseError(error, error=error)
await asyncio.sleep(1)

except HttpResponseError as error:
if self._start_range is None and error.response.status_code == 416:
# Get range will fail on an empty file. If the user did not
Expand All @@ -377,12 +384,6 @@ async def _initial_request(self):
else:
process_storage_error(error)

except ClientPayloadError as error:
retry_total -= 1
if retry_total <= 0:
raise ServiceResponseError(error, error=error)
await asyncio.sleep(1)

# get page ranges to optimize downloading sparse page blob
if response.properties.blob_type == 'PageBlob':
try:
Expand Down

0 comments on commit e40d3e1

Please sign in to comment.