misc: add timeouts to requests (#61362)

This commit is contained in:
Frédéric Péters 2023-05-25 09:11:07 +02:00
parent 3a43f1c597
commit 6a95789905
2 changed files with 4 additions and 2 deletions

View File

@ -70,7 +70,7 @@ class AuthenticAdapter(DefaultAdapter):
continue
verify_ssl_certificate = mellon_utils.get_setting(idp, 'VERIFY_SSL_CERTIFICATE')
try:
response = requests.get(idp['METADATA_URL'], verify=verify_ssl_certificate)
response = requests.get(idp['METADATA_URL'], verify=verify_ssl_certificate, timeout=30)
response.raise_for_status()
except requests.exceptions.RequestException:
if os.path.exists(metadata_cache_filename):

View File

@ -118,7 +118,9 @@ class CountryWidget(forms.Select):
passerelle_url = list(settings.KNOWN_SERVICES['passerelle'].values())[0]['url']
country_url = urljoin(passerelle_url, '/csvdatasource/pays/data')
try:
self.choices = [(x['id'], x['text']) for x in requests.get(country_url).json()['data']]
self.choices = [
(x['id'], x['text']) for x in requests.get(country_url, timeout=30).json()['data']
]
except ValueError:
self.choices = []
super(forms.Select, self).__init__(attrs=attrs, choices=self.choices)