always good practive to catch errors
Prevents printing a trace log, this except in particular catches all errors thrown by requests: https://stackoverflow.com/a/16511493
This commit is contained in:
parent
fe7baed7f9
commit
4856e55d6c
|
@ -18,9 +18,12 @@ TIMEOUT = 5 # Seconds
|
|||
|
||||
|
||||
def do_heatlhcheck(url):
|
||||
headers = {'User-Agent': 'healthcheck'}
|
||||
response = requests.get(url, headers=headers, timeout=TIMEOUT)
|
||||
return response.status_code == 200
|
||||
try:
|
||||
headers = {'User-Agent': 'healthcheck'}
|
||||
response = requests.get(url, headers=headers, timeout=TIMEOUT)
|
||||
return response.status_code == 200
|
||||
except requests.exceptions.RequestException:
|
||||
return false
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in New Issue