mirror of
https://github.com/Viren070/MediaFusion.git
synced 2025-12-01 23:21:11 +01:00
Fix health check endpoint due to httpx session
This commit is contained in:
+7
-7
@@ -141,14 +141,14 @@ async def get_home(request: Request):
|
||||
@wrappers.exclude_rate_limit
|
||||
async def health():
|
||||
start_time = asyncio.get_event_loop().time()
|
||||
async with httpx.AsyncClient(proxy=settings.requests_proxy_url) as session:
|
||||
async with httpx.AsyncClient(proxy=settings.requests_proxy_url) as client:
|
||||
try:
|
||||
async with session.head("https://www.google.com", timeout=10) as response:
|
||||
return {
|
||||
"status": "healthy",
|
||||
"status_code": response.status,
|
||||
"time": asyncio.get_event_loop().time() - start_time,
|
||||
}
|
||||
response = await client.head("https://www.google.com", timeout=10)
|
||||
return {
|
||||
"status": "healthy",
|
||||
"status_code": response.status_code,
|
||||
"time": asyncio.get_event_loop().time() - start_time,
|
||||
}
|
||||
except Exception as e:
|
||||
logging.error("Health check failed: %s", e)
|
||||
raise HTTPException(status_code=503, detail="Health check failed.")
|
||||
|
||||
Reference in New Issue
Block a user