Skip to content

Commit 0d84453

Browse files
committed
add random 1-5s sleep before laz download retry
1 parent b72673b commit 0d84453

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/core/src/bag3d/core/assets/ahn/download.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import json
2+
import time
3+
import random
24
from pathlib import Path
35
from typing import Mapping, Union
46
from hashlib import new as hash_new, algorithms_available
@@ -414,6 +416,15 @@ def download_ahn_laz(
414416
def download_laz(
415417
file_size, fpath, is_new, nr_retries, success, url, url_laz, verify_ssl
416418
):
419+
if url is None:
420+
url_laz = None
421+
fpath_download = Path()
422+
success = False
423+
is_new = False
424+
file_size = 0.0
425+
logger.error("Cannot download from url with value None")
426+
return file_size, fpath, is_new, success, url_laz
427+
417428
fpath_download = Path()
418429
for i in range(nr_retries):
419430
fpath_download = download_file(
@@ -434,6 +445,7 @@ def download_laz(
434445
logger.error(f"Download failed after {i + 1} retries")
435446
else:
436447
logger.warning(f"Retrying ({i + 1}/{nr_retries})")
448+
time.sleep(random.randrange(1, 5))
437449
else:
438450
success = True
439451
is_new = True

0 commit comments

Comments
 (0)