Skip to content

Commit 669b182

Browse files
authored
Merge pull request #1558 from dandi/gh-1556
Continue retrying downloads on retriable statuses
2 parents 29009f6 + bb05a23 commit 669b182

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

dandi/download.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,8 +1103,11 @@ def _check_if_more_attempts_allowed(
11031103
downloaded_in_attempt,
11041104
)
11051105
attempts_allowed += 1
1106+
if attempt >= attempts_allowed:
1107+
lgr.debug("%s - download failed after %d attempts: %s", path, attempt, exc)
1108+
return None
11061109
# TODO: actually we should probably retry only on selected codes,
1107-
if exc.response is not None:
1110+
elif exc.response is not None:
11081111
if exc.response.status_code not in (
11091112
400, # Bad Request, but happened with gider:
11101113
# https://github.com/dandi/dandi-cli/issues/87
@@ -1141,11 +1144,12 @@ def _check_if_more_attempts_allowed(
11411144
exc,
11421145
)
11431146
else:
1144-
lgr.debug("%s - download failed: %s", path, exc)
1145-
return None
1146-
elif attempt >= attempts_allowed:
1147-
lgr.debug("%s - download failed after %d attempts: %s", path, attempt, exc)
1148-
return None
1147+
lgr.debug(
1148+
"%s - download failed on attempt #%d: %s, will sleep a bit and retry",
1149+
path,
1150+
attempt,
1151+
exc,
1152+
)
11491153
# if is_access_denied(exc) or attempt >= 2:
11501154
# raise
11511155
# sleep a little and retry

0 commit comments

Comments
 (0)