Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 85017b6

Browse files
updated login services
1 parent c09ecb6 commit 85017b6

File tree

1 file changed

+10
-27
lines changed

1 file changed

+10
-27
lines changed

‎src/main/main.py‎

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -450,33 +450,16 @@ async def v1_gateway(request: Request, path: str):
450450
return JSONResponse(content=response, status_code=200, headers={"Content-Type": "application/json"})
451451

452452
app_logger.info(msg="All cached responses not found- Must Be a Slow Day")
453-
454-
try:
455-
# 5 minutes timeout on resource fetching from backend - some resources may take very long
456-
tasks = [requester(api_url=api_url, timeout=9600) for api_url in api_urls]
457-
responses = await asyncio.gather(*tasks)
458-
459-
except httpx.HTTPError as http_err:
460-
app_logger.info(msg=f"Errors when making requests : {str(http_err)}")
461-
responses = []
462-
463-
app_logger.info(msg=f"Request Responses returned : {len(responses)}")
464-
465-
for i, response in enumerate(responses):
466-
if response and response.get("status", False) and response.get('payload'):
467-
api_url = api_urls[i]
468-
# NOTE, Cache is being set to a ttl of one hour here
469-
await redis_cache.set(key=api_url, value=response, ttl=60 * 60)
470-
app_logger.info(msg=f"Server Responded for this Resource {api_url}")
471-
return JSONResponse(content=response, status_code=200, headers={"Content-Type": "application/json"})
472-
else:
473-
# The reason for this algorithm is because sometimes the cron server is busy this way no matter
474-
# what happens a response is returned
475-
app_logger.warning(msg=f"""
476-
Server Failed To Respond - Or Data Not Found
477-
Original Request URL : {api_urls[i]}
478-
Actual Response : {response}
479-
""")
453+
for api_url in api_urls:
454+
try:
455+
# 5 minutes timeout on resource fetching from backend - some resources may take very long
456+
response = await requester(api_url=api_url, timeout=9600)
457+
if response and response.get("status", False) and response.get('payload'):
458+
# NOTE, Cache is being set to a ttl of one hour here
459+
await redis_cache.set(key=api_url, value=response, ttl=60 * 60)
460+
return JSONResponse(content=response, status_code=200, headers={"Content-Type": "application/json"})
461+
except httpx.HTTPError as http_err:
462+
app_logger.info(msg=f"Errors when making requests : {str(http_err)}")
480463

481464
mess = "All API Servers failed to respond - Or there is no Data for the requested resource and parameters"
482465
app_logger.warning(msg=mess)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /