I have a question regarding the reconnection process between a ray cluster and a FastAPI server. On FastAPI I init/connect to the ray cluster in the startup event:
@app.on_event("startup")
async def init_ray():
...
ray.init(address=f'{ray_head_host}:{ray_head_port}', _redis_password=ray_redis_password, namespace=ray_serve_namespace)
...
In the case of a restart of the ray cluster I ran into a problem when I want to use the ray API in some FastAPI routes:
Exception: Ray Client is not connected. Please connect by calling `ray.connect`.
So it seems that the connection from FastAPI to ray is lost (this is also confirmed by ray.is_initilized() ==> False). But if I try to re-connect using ray.init() I got the following error:
Exception: ray.connect() called, but ray client is already connected
I also tried to call ray.shutdown() infornt of the re-init call without success.
Maybe someone has an idea how to reconnect from FastAPI?