fix: API does not suspend after 1st request
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
from fastapi import Request
|
from fastapi import Request
|
||||||
import httpx
|
import httpx
|
||||||
from pprint import pprint
|
|
||||||
from src.database import get_config_from_db
|
from src.database import get_config_from_db
|
||||||
|
|
||||||
|
|
||||||
@@ -22,7 +21,7 @@ async def get_data_from_ontap(request: Request, logger, endpoint: str, query_str
|
|||||||
logger.debug("Got the config from REDIS: %s", config)
|
logger.debug("Got the config from REDIS: %s", config)
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
async with request.state.requests_client as _client:
|
client = request.state.requests_client
|
||||||
for cluster in config:
|
for cluster in config:
|
||||||
print(f"\n\n looping, {cluster}")
|
print(f"\n\n looping, {cluster}")
|
||||||
url = f"https://{cluster.hostname}/api/{endpoint}"
|
url = f"https://{cluster.hostname}/api/{endpoint}"
|
||||||
@@ -30,7 +29,7 @@ async def get_data_from_ontap(request: Request, logger, endpoint: str, query_str
|
|||||||
url += f"?{query_string}"
|
url += f"?{query_string}"
|
||||||
try:
|
try:
|
||||||
logger.debug(f"Fetching data from ONTAP: {url}")
|
logger.debug(f"Fetching data from ONTAP: {url}")
|
||||||
response = await _client.get(url, auth=(cluster.username, cluster.password))
|
response = await client.get(url, auth=(cluster.username, cluster.password))
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
results.extend(response.json()["records"])
|
results.extend(response.json()["records"])
|
||||||
except httpx.HTTPError as e:
|
except httpx.HTTPError as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user