Unverified Commit b6909aa2 authored by ishandhanani's avatar ishandhanani Committed by GitHub
Browse files

fix: allow `launch_dummy_health_check_server` to start inside of running asyncio loop (#6330)

parent f8728357
...@@ -1847,6 +1847,8 @@ def get_cuda_version(): ...@@ -1847,6 +1847,8 @@ def get_cuda_version():
def launch_dummy_health_check_server(host, port): def launch_dummy_health_check_server(host, port):
import asyncio
import uvicorn import uvicorn
from fastapi import FastAPI, Response from fastapi import FastAPI, Response
...@@ -1862,13 +1864,27 @@ def launch_dummy_health_check_server(host, port): ...@@ -1862,13 +1864,27 @@ def launch_dummy_health_check_server(host, port):
"""Check the health of the http server.""" """Check the health of the http server."""
return Response(status_code=200) return Response(status_code=200)
uvicorn.run( config = uvicorn.Config(
app, app,
host=host, host=host,
port=port, port=port,
timeout_keep_alive=5, timeout_keep_alive=5,
loop="uvloop", loop="auto",
log_config=None,
log_level="warning",
) )
server = uvicorn.Server(config=config)
try:
loop = asyncio.get_running_loop()
logger.info(
f"Dummy health check server scheduled on existing loop at {host}:{port}"
)
loop.create_task(server.serve())
except RuntimeError:
logger.info(f"Starting dummy health check server at {host}:{port}")
server.run()
def create_checksum(directory: str): def create_checksum(directory: str):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment