Skip to content

Commit

Permalink
Set timeout to 10 seconds for all external requests
Browse files Browse the repository at this point in the history
  • Loading branch information
bartjkdp committed Nov 1, 2022
1 parent 8bd90ab commit 3a130a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def send(self, endpoint, additional_headers):
'SOAPAction': self.SOAP_ACTION
}

response = requests.post(endpoint, self.tostring(), headers={ **headers, **additional_headers })
response = requests.post(endpoint, self.tostring(), headers={ **headers, **additional_headers }, timeout=10)
response.raise_for_status()

return etree.fromstring(response.content)
Expand Down
6 changes: 3 additions & 3 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def buitenbeter():
}

url = urljoin(app.config['SIGNALEN_ENDPOINT'], '/signals/category/prediction')
response = requests.post(url, data=json.dumps(data), headers={ **headers, **app.config['ADDITIONAL_SIGNALEN_HEADERS'] })
response = requests.post(url, data=json.dumps(data), headers={ **headers, **app.config['ADDITIONAL_SIGNALEN_HEADERS'] }, timeout=10)

sub_category = urljoin(app.config['SIGNALEN_ENDPOINT'], '/signals/v1/public/terms/categories/overig/sub_categories/overig')

Expand Down Expand Up @@ -153,7 +153,7 @@ def buitenbeter():
}

url = urljoin(app.config['SIGNALEN_ENDPOINT'], '/signals/v1/private/signals/')
response = requests.post(url, data=json.dumps(data), headers={ **headers, **app.config['ADDITIONAL_SIGNALEN_HEADERS'] })
response = requests.post(url, data=json.dumps(data), headers={ **headers, **app.config['ADDITIONAL_SIGNALEN_HEADERS'] }, timeout=10)

signal_data = response.json()
signal_id = signal_data.get('signal_id')
Expand Down Expand Up @@ -182,7 +182,7 @@ def buitenbeter():


url = urljoin(app.config['SIGNALEN_ENDPOINT'], f'/signals/v1/public/signals/{signal_id}/attachments/')
response = requests.post(url, data=data, files=files, headers=app.config['ADDITIONAL_SIGNALEN_HEADERS'])
response = requests.post(url, data=data, files=files, headers=app.config['ADDITIONAL_SIGNALEN_HEADERS'], timeout=10)
if not response.ok:
app.logger.info(f'Could not create attachment in Signalen: {response.text}')
return 'Could not create attachment in Signalen', 400
Expand Down

0 comments on commit 3a130a1

Please sign in to comment.