From 8f7ad0330a711e5c681bd27483656d308d86bd06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=BE=20=D0=9A=D0=B0=D1=82?= =?UTF-8?q?=D1=8E=D1=85=D0=B0?= Date: Thu, 15 Aug 2024 13:53:46 +0300 Subject: [PATCH] Increase max attempts for download to 7 + add some randomization on wait timeout --- subpackages/utils/source/odood/utils/package.d | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/subpackages/utils/source/odood/utils/package.d b/subpackages/utils/source/odood/utils/package.d index edcea14..3ddc3eb 100644 --- a/subpackages/utils/source/odood/utils/package.d +++ b/subpackages/utils/source/odood/utils/package.d @@ -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; @@ -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);