summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHimanshu Shekhar <himanshushekharb16@gmail.com>2017-04-30 20:24:25 +0530
committerHimanshu Shekhar <himanshushekharb16@gmail.com>2017-04-30 20:24:25 +0530
commit5dcc9607bd89cd7db09b69f7e71a963bfcf6c80a (patch)
tree79c8d53cef12af8523396bc8e7f1f9333d8c620f /scripts
parent130c62eb1f2e024d974deccbe7ad845663424d04 (diff)
downloadpsutil-5dcc9607bd89cd7db09b69f7e71a963bfcf6c80a.tar.gz
implement timeout in http requests
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/internal/check_broken_links.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/scripts/internal/check_broken_links.py b/scripts/internal/check_broken_links.py
index 76ed8da7..9ae5e644 100755
--- a/scripts/internal/check_broken_links.py
+++ b/scripts/internal/check_broken_links.py
@@ -54,6 +54,8 @@ HERE = os.path.abspath(os.path.dirname(__file__))
REGEX = r'(?:http|ftp|https)?://' \
r'(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+'
+REQUEST_TIMEOUT = 30
+
# There are some status codes sent by websites on HEAD request.
# Like 503 by Microsoft, and 401 by Apple
# They need to be sent GET request
@@ -84,11 +86,11 @@ def validate_url(url):
Uses requests module.
"""
try:
- res = requests.head(url)
+ res = requests.head(url, timeout=REQUEST_TIMEOUT)
# some websites deny 503, like Microsoft
# and some send 401, like Apple, observations
if (not res.ok) and (res.status_code in RETRY_STATUSES):
- res = requests.get(url)
+ res = requests.get(url, timeout=REQUEST_TIMEOUT)
return res.ok
except requests.exceptions.RequestException:
return False