Workers parameter is ignored when starting server from Config #2215
-
The following works as expected (it creates 4 workers): import uvicorn
from fastapi import FastAPI, Response
if __name__ == "__main__":
uvicorn.run(
"main:app",
host="0.0.0.0",
port=8123,
workers=4,
)
app = FastAPI()
@app.get("/")
async def ack() -> Response:
"""Health check."""
return Response(status_code=200) while the following doesn't (it's ignoring the workers parameter): import uvicorn
from fastapi import FastAPI, Response
if __name__ == "__main__":
config = uvicorn.Config(
"main:app",
host="0.0.0.0",
port=8123,
workers=4,
)
uvicorn.Server(config).run()
app = FastAPI()
@app.get("/")
async def ack() -> Response:
"""Health check."""
return Response(status_code=200) tested on Python 3.10.13 with:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Correct. |
Beta Was this translation helpful? Give feedback.
-
Faced with this issue, why is this intended the way it is? What is stopping me from forking multiple processes to start multiple uvicorn processes, at least to circumvent python's GIL for better parallelization on CPU-bound tasks? I imagine stateful params like I imagine that's what process managers are for, though. |
Beta Was this translation helpful? Give feedback.
Correct.