Skip to content

Commit 94fd672

Browse files
committed
More?
1 parent b822577 commit 94fd672

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

datapackage_pipelines_migdar/flows/broken_links.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ def func(row):
4949
backoff = 10
5050
try:
5151
print('%s:CHECK:%s' % (datetime.datetime.now().isoformat(), row["url"]))
52-
for _ in range(5):
53-
resp = requests.get(row['url'], allow_redirects=True, headers=HEADERS, timeout=10, stream=True)
52+
for _ in range(3):
53+
resp = requests.head(row['url'], allow_redirects=True, headers=HEADERS, timeout=10)
5454
if resp.status_code == 429:
5555
time.sleep(backoff)
5656
backoff *= 2
57-
error = 'Server Overload'
57+
error = 'Server Overload'
5858
continue
5959
elif resp.status_code >= 300:
6060
error = '%s: %s' % (resp.status_code, resp.reason)
@@ -66,6 +66,8 @@ def func(row):
6666
error = str(e.__class__.__name__)
6767
except requests.exceptions.BaseHTTPError as e:
6868
error = str(e.__class__.__name__)
69+
except Exception as e:
70+
error = str(e.__class__.__name__)
6971
if error:
7072
print('%s:ERROR:%s: %s' % (datetime.datetime.now().isoformat(), row['url'], error))
7173
row['error'] = error

0 commit comments

Comments
 (0)