Skip to content

Commit a1ac930

Browse files
trop[bot]MarshallOfSound
authored andcommitted
chore: retry for the meta dumper a few times (#14242)
1 parent ed8396c commit a1ac930

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

script/upload-index-json.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@
1515
version = sys.argv[1]
1616
authToken = os.getenv('META_DUMPER_AUTH_HEADER')
1717

18+
def get_content(retry_count = 5):
19+
try:
20+
request = urllib2.Request(
21+
BASE_URL + version,
22+
headers={"Authorization" : authToken}
23+
)
24+
25+
return urllib2.urlopen(
26+
request
27+
).read()
28+
except Exception as e:
29+
if retry_count == 0:
30+
raise e
31+
return get_content(retry_count - 1)
32+
1833
def main():
1934
if not authToken or authToken == "":
2035
raise Exception("Please set META_DUMPER_AUTH_HEADER")
@@ -23,14 +38,7 @@ def main():
2338
safe_mkdir(OUT_DIR)
2439
index_json = os.path.relpath(os.path.join(OUT_DIR, 'index.json'))
2540

26-
request = urllib2.Request(
27-
BASE_URL + version,
28-
headers={"Authorization" : authToken}
29-
)
30-
31-
new_content = urllib2.urlopen(
32-
request
33-
).read()
41+
new_content = get_content()
3442

3543
with open(index_json, "w") as f:
3644
f.write(new_content)

0 commit comments

Comments
 (0)