-
-
Notifications
You must be signed in to change notification settings - Fork 749
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
Allow worker kwargs #2445
base: master
Are you sure you want to change the base?
Allow worker kwargs #2445
Conversation
in my test,i can not get worker_kwargs as what i expect. from pathlib import Path
import uvicorn
import a
app = a.app
print("-------- queue ----------")
if __name__ == '__main__':
max_workers = 4
uvicorn.run(f"{Path(a.__file__).stem}:app", host='0.0.0.0', port=8000, reload=True,
worker_kwargs={"shared_queue": [1, 2, 3, 4]}) a.py as follow from fastapi import FastAPI
app = FastAPI()
@app.get("/city/{city_id}")
def get_city(city_id: str):
return {"city_id": city_id, "app": dir(app)} curl result
in my opinion,i can get shared_queue in app but not. |
The option only applies when you use the factory option (maybe I should call it If you made your
you should see the shared_queue passed. If you actually intend to use this as a shared queue between workers that has items added/removed (as the variable name suggests at least) you should use a shared memory list or a SyncManager list |
Summary
Addresses #2377
This PR allows passing
worker_kwargs
to all workers when usinguvicorn.run
. This is more flexible than using environment variables because it means you canChecklist