File tree Expand file tree Collapse file tree 2 files changed +21
-11
lines changed
azure-storage-blob/azure/storage/blob/aio
azure-storage-file-share/azure/storage/fileshare/aio Expand file tree Collapse file tree 2 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -527,11 +527,11 @@ async def read(self, size: Optional[int] = -1) -> T:
527
527
except HttpResponseError as error :
528
528
process_storage_error (error )
529
529
try :
530
- next_chunk = next (dl_tasks )
530
+ for _ in range (0 , len (done )):
531
+ next_chunk = next (dl_tasks )
532
+ running_futures .add (asyncio .ensure_future (downloader .process_chunk (next_chunk )))
531
533
except StopIteration :
532
534
break
533
- else :
534
- running_futures .add (asyncio .ensure_future (downloader .process_chunk (next_chunk )))
535
535
536
536
if running_futures :
537
537
# Wait for the remaining downloads to finish
@@ -683,11 +683,11 @@ async def readinto(self, stream: IO[T]) -> int:
683
683
except HttpResponseError as error :
684
684
process_storage_error (error )
685
685
try :
686
- next_chunk = next (dl_tasks )
686
+ for _ in range (0 , len (done )):
687
+ next_chunk = next (dl_tasks )
688
+ running_futures .add (asyncio .ensure_future (downloader .process_chunk (next_chunk )))
687
689
except StopIteration :
688
690
break
689
- else :
690
- running_futures .add (asyncio .ensure_future (downloader .process_chunk (next_chunk )))
691
691
692
692
if running_futures :
693
693
# Wait for the remaining downloads to finish
Original file line number Diff line number Diff line change @@ -445,18 +445,28 @@ async def readinto(self, stream):
445
445
]
446
446
while running_futures :
447
447
# Wait for some download to finish before adding a new one
448
- _done , running_futures = await asyncio .wait (
448
+ done , running_futures = await asyncio .wait (
449
449
running_futures , return_when = asyncio .FIRST_COMPLETED )
450
450
try :
451
- next_chunk = next (dl_tasks )
451
+ for task in done :
452
+ task .result ()
453
+ except HttpResponseError as error :
454
+ process_storage_error (error )
455
+ try :
456
+ for _ in range (0 , len (done )):
457
+ next_chunk = next (dl_tasks )
458
+ running_futures .add (asyncio .ensure_future (downloader .process_chunk (next_chunk )))
452
459
except StopIteration :
453
460
break
454
- else :
455
- running_futures .add (asyncio .ensure_future (downloader .process_chunk (next_chunk )))
456
461
457
462
if running_futures :
458
463
# Wait for the remaining downloads to finish
459
- await asyncio .wait (running_futures )
464
+ done , _running_futures = await asyncio .wait (running_futures )
465
+ try :
466
+ for task in done :
467
+ task .result ()
468
+ except HttpResponseError as error :
469
+ process_storage_error (error )
460
470
return self .size
461
471
462
472
async def download_to_stream (self , stream , max_concurrency = 1 ):
You can’t perform that action at this time.
0 commit comments