From 362c470b3c769f62288023c62ae8c35ad6e13403 Mon Sep 17 00:00:00 2001 From: "Magel, Denis" Date: Thu, 18 Sep 2025 18:36:51 +0200 Subject: [PATCH] fix: API does not suspend after 1st request --- src/utils.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/utils.py b/src/utils.py index 94d11b6..5f5724a 100644 --- a/src/utils.py +++ b/src/utils.py @@ -1,7 +1,6 @@ import logging from fastapi import Request import httpx -from pprint import pprint from src.database import get_config_from_db @@ -22,20 +21,20 @@ async def get_data_from_ontap(request: Request, logger, endpoint: str, query_str logger.debug("Got the config from REDIS: %s", config) results = [] - async with request.state.requests_client as _client: - for cluster in config: - print(f"\n\n looping, {cluster}") - url = f"https://{cluster.hostname}/api/{endpoint}" - if query_string: - url += f"?{query_string}" - try: - logger.debug(f"Fetching data from ONTAP: {url}") - response = await _client.get(url, auth=(cluster.username, cluster.password)) - response.raise_for_status() - results.extend(response.json()["records"]) - except httpx.HTTPError as e: - logger.error(f"HTTP error occurred: {e}") - return None + client = request.state.requests_client + for cluster in config: + print(f"\n\n looping, {cluster}") + url = f"https://{cluster.hostname}/api/{endpoint}" + if query_string: + url += f"?{query_string}" + try: + logger.debug(f"Fetching data from ONTAP: {url}") + response = await client.get(url, auth=(cluster.username, cluster.password)) + response.raise_for_status() + results.extend(response.json()["records"]) + except httpx.HTTPError as e: + logger.error(f"HTTP error occurred: {e}") + return None return results