- 
                Notifications
    
You must be signed in to change notification settings  - Fork 484
 
Refactor LLMProxy to run Uvicorn in isolated process #255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| 
           @beanie00 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information. 
 Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”), 
 
 
  | 
    
Summary
This PR refactors the
LLMProxy.start()logic to launch the Uvicorn proxy server in a fully isolated process usingmultiprocessing.spawn.The previous implementation ran the server in a background thread, which caused persistent connection and transport errors when Ray forked workers or when LiteLLM reused existing event loops.
Motivation
In the previous design, the proxy shared its asyncio loop and open network sockets with the parent process. When Ray forked new workers or reused existing
aiohttp.ClientSessionobjects, the same TCP socket descriptors were inherited in an invalid state. This led to repeated I/O failures like:These errors occurred because aiohttp tried to write to a “closing transport”, a socket that had already been closed in the parent process or invalidated by
fork().Changes