We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e8c82fd commit 211702bCopy full SHA for 211702b
1 file changed
src/urlcache.py
@@ -1,5 +1,5 @@
1
# SPDX-License-Identifier: MIT
2
-import os, sys, os.path
+import os, sys, os.path, time
3
from dataclasses import dataclass
4
5
from urllib import request
@@ -58,14 +58,16 @@ def get_block(self, blk):
58
size += self.BLOCKSIZE
59
60
size = min(off + size, self.size) - off
61
- for retry in range(6):
+ retries = 5
62
+ for retry in range(retries + 1):
63
try:
64
data = self.get_partial(off, size)
65
except Exception as e:
- if retry == 5:
66
+ if retry == retries:
67
print(f"Exceeded maximum retries downloading data.")
68
sys.exit(1)
- print(f"Error downloading data ({e}), retrying... ({retry + 1}/5)")
69
+ print(f"Error downloading data ({e}), retrying... ({retry + 1}/{retries})")
70
+ time.sleep(1)
71
else:
72
break
73
0 commit comments