@@ -450,33 +450,16 @@ async def v1_gateway(request: Request, path: str):
450
450
return JSONResponse (content = response , status_code = 200 , headers = {"Content-Type" : "application/json" })
451
451
452
452
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 )} " )
480
463
481
464
mess = "All API Servers failed to respond - Or there is no Data for the requested resource and parameters"
482
465
app_logger .warning (msg = mess )
0 commit comments