Skip to content

Commit

Permalink
Merge pull request #730 from Amsterdam/improvement/upgrade-bag-api-ti…
Browse files Browse the repository at this point in the history
…meout

Increase timeout for BAG and BRK API requests from 0.5 to 5 seconds
  • Loading branch information
remyvdwereld authored Nov 25, 2024
2 parents 39c3a81 + b69f0bd commit 286b02b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/utils/queries_bag_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def fetch_bag_data_by_nummeraanduiding_id(nummeraanduiding_id):
"""
url = f"{settings.BAG_BENKAGG_API_URL}{nummeraanduiding_id}"
try:
response = requests.get(url, timeout=0.5)
response = requests.get(url, timeout=5)
response.raise_for_status() # Raise HTTPError for bad responses (4xx and 5xx)
return response.json()
except Exception as exc:
Expand Down
4 changes: 2 additions & 2 deletions app/utils/queries_brk_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def request_new_token():
try:
logger.error("token req url", token_request_url)
logger.error("token req payload", payload)
response = requests.post(token_request_url, data=payload, timeout=0.5)
response = requests.post(token_request_url, data=payload, timeout=5)
except Exception as e:
logger.error("Request token error: ", e)
response.raise_for_status()
Expand Down Expand Up @@ -100,7 +100,7 @@ def request_brk_data(bag_id):
settings.BRK_API_OBJECT_EXPAND_URL,
params={"verblijfsobjecten__id": bag_id},
headers=headers,
timeout=0.5,
timeout=5,
)
except Exception as e:
logger.error("ERR: ", e)
Expand Down
2 changes: 1 addition & 1 deletion app/utils/tests/tests_queries_bag_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_fetch_bag_data_by_nummeraanduiding_id_success(self, mock_requests_get):

self.assertEqual(result, {"data": "some_data"})
mock_requests_get.assert_called_once_with(
f"{settings.BAG_BENKAGG_API_URL}123456789", timeout=0.5
f"{settings.BAG_BENKAGG_API_URL}123456789", timeout=5
)

@patch("requests.get")
Expand Down

0 comments on commit 286b02b

Please sign in to comment.