Skip to content

Commit a4751de

Browse files
chore: Sleep a bit when encountering a 429 in doc link checker (#6286)
1 parent 0aa5ef8 commit a4751de

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

chore/check-links-in-doc.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,24 @@
77
import os
88
import codecs
99
import requests
10+
import time
1011

1112
URLS = []
1213

13-
def check_external_url(url):
14+
def check_external_url(url, tries = 0):
15+
if tries > 10:
16+
raise Exception(f"{url} still 429ed after {tries} tries")
1417
# only checking the local or github files
1518
# we may comment since later and check everything but it takes time
1619
if "spoon.forge" not in url and "INRIA/spoon" not in url : return
1720

1821
if url in URLS: return
1922
r = requests.get(url, headers = {"user-agent": "Mozilla/5.0 FakeBrowser"}) # sf.net, elsevier use stupid UA detection
23+
if r.status_code == 429:
24+
print("Got 429, sleeping for a bit")
25+
print(r.text)
26+
time.sleep(2)
27+
return check_external_url(url, tries=tries + 1)
2028
if r.status_code != 200:
2129
raise Exception(url+" invalid "+str(r.status_code))
2230
URLS.append(url)

0 commit comments

Comments
 (0)