File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4747
4848logger = logging .getLogger (__name__ )
4949
50- BATCH_DOWNLOAD_MAX_RETRIES : Final = 3
50+ BATCH_DOWNLOAD_MAX_RETRIES : Final = 5
5151
5252
5353class BatchHttpAPI (BentoHttpAPI ):
@@ -457,6 +457,11 @@ def _download_batch_file(
457457 with open (output_path , mode = mode ) as f :
458458 for chunk in response .iter_content (chunk_size = HTTP_STREAMING_READ_SIZE ):
459459 f .write (chunk )
460+
461+ # Successfully wrote some data, reset attempts counter
462+ if attempts > 0 :
463+ attempts = 0
464+ logger .info (f"Resumed download of { output_path .name } ." )
460465 except BentoHttpError as exc :
461466 if exc .http_status == 429 :
462467 wait_time = int (exc .headers .get ("Retry-After" , 1 ))
@@ -465,10 +470,11 @@ def _download_batch_file(
465470 raise
466471 except Exception as exc :
467472 if attempts < BATCH_DOWNLOAD_MAX_RETRIES :
473+ attempts += 1
468474 logger .error (
469- f"Retrying download of { output_path .name } due to error: { exc } " ,
475+ f"Retrying download of { output_path .name } due to error, "
476+ f"{ attempts } /{ BATCH_DOWNLOAD_MAX_RETRIES } : { exc } " ,
470477 )
471- attempts += 1
472478 continue # try again
473479 raise BentoError (f"Error downloading file: { exc } " ) from None
474480 else :
You can’t perform that action at this time.
0 commit comments