Skip to content

Commit

Permalink
Increase max attempts for download to 7
Browse files Browse the repository at this point in the history
+ add some randomization on wait timeout
  • Loading branch information
katyukha committed Aug 15, 2024
1 parent 68ea259 commit 8f7ad03
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions subpackages/utils/source/odood/utils/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ class OdoodDownloadException : OdoodException
void download(
in string url,
in Path dest_path,
in Duration timeout=15.seconds,
in ubyte max_retries=5) {
in Duration timeout=20.seconds,
in ubyte max_retries=7) {
import requests: Request, Response, RequestException;
import requests.streams: ConnectError, TimeoutException, NetworkException;

Expand Down Expand Up @@ -123,12 +123,12 @@ void download(
// if it is last attempt and we got error, then throw it as is
if (attempt == max_retries)
throw new OdoodDownloadException(
"Cannot download %s because max attempts reached: %s".format(
url, e.toString),
"Cannot download %s because max (%s) attempts reached: %s".format(
url, attempt, e.toString),
e);

// sleep for 1 second in case of failure
Thread.sleep((attempt+1).seconds);
// sleep for some time in case of failure
Thread.sleep((attempt + uniform(1, 5)).seconds);
warningf(
"Cannot download %s because %s. Attempt %s/%s. Retrying",
url, e.msg, attempt+1, max_retries);
Expand Down

0 comments on commit 8f7ad03

Please sign in to comment.