Apply timeouts everywhere

This commit is contained in:
redfast00 2020-02-14 13:21:21 +01:00
parent d37baaec70
commit be9929fd92
No known key found for this signature in database
GPG key ID: 5946E0E34FD0553C

View file

@ -128,7 +128,7 @@ def revoke(admin_username):
def slotmachien_request(username, command): def slotmachien_request(username, command):
r = requests.post(config.slotmachien_url, json={ r = requests.post(config.slotmachien_url, json={
'username': username, 'token': config.slotmachien_token, 'text': command}) 'username': username, 'token': config.slotmachien_token, 'text': command}, timeout=1)
return r.text return r.text
@ -204,7 +204,7 @@ def cammiechat(username):
headers = { headers = {
"X-Username": username "X-Username": username
} }
requests.post("https://kelder.zeus.ugent.be/messages/", data=request.values.get('text').strip(), headers=headers) requests.post("https://kelder.zeus.ugent.be/messages/", data=request.values.get('text').strip(), headers=headers, timeout=1)
return mattermost_response("Message sent", ephemeral=True) return mattermost_response("Message sent", ephemeral=True)
@ -304,7 +304,7 @@ def resto_menu():
today = datetime.today() today = datetime.today()
url = "https://zeus.ugent.be/hydra/api/2.0/resto/menu/nl/{}/{}/{}.json"\ url = "https://zeus.ugent.be/hydra/api/2.0/resto/menu/nl/{}/{}/{}.json"\
.format(today.year, today.month, today.day) .format(today.year, today.month, today.day)
resto = requests.get(url).json() resto = requests.get(url, timeout=1).json()
if not resto["open"]: if not resto["open"]:
return 'De resto is vandaag gesloten.' return 'De resto is vandaag gesloten.'