Add timeouts to the calls to the GTFS-R API

This commit is contained in:
Nahuel Lofeudo 2023-11-11 15:46:51 +00:00
parent 3c3199e3eb
commit b5d9fa1dd8
1 changed files with 1 additions and 1 deletions

View File

@ -257,7 +257,7 @@ class GTFSClient():
# Poll GTFS-R API # Poll GTFS-R API
if self.gtfs_r_api_key != "": if self.gtfs_r_api_key != "":
headers = {"x-api-key": self.gtfs_r_api_key} headers = {"x-api-key": self.gtfs_r_api_key}
response = requests.get(url = self.gtfs_r_url, headers = headers) response = requests.get(url = self.gtfs_r_url, headers = headers, timeout=(2, 10))
if response.status_code != 200: if response.status_code != 200:
print("GTFS-R sent non-OK response: {}\n{}".format(response.status_code, response.text)) print("GTFS-R sent non-OK response: {}\n{}".format(response.status_code, response.text))
return ({}, [], []) return ({}, [], [])