Replies: 1 comment
-
Second this, and have a very basic PR to handle this by supporting an arguments of https://github.com/SaravananSathyanandhaQC/uvicorn/tree/worker-kwargs I have two use cases where this would be valuable (both in scenarios with multiple workers hence have to use the factory):
|
Beta Was this translation helpful? Give feedback.
-
I am currently running uvicorn programmatically with single worker.
When running with single worker, application can be initialized and passed to uvicorn.run() function, therefore I could accept / apply application options from outside (command line ..etc)
However, as I proceed to change to using multiple workers, unvicorn.run() will only accept import string, not application instance itself.
as far as I know, config.load() will parse this string and import_from_string will retrieve application from this string.
For my app to be custom initialized with options provided from the command line, I would like to use the app_factory option. But as of now, self.loaded_app() (which is my app_factory method) is set to accept no argument.
uvicorn/uvicorn/config.py
Lines 439 to 440 in c23cd24
I have made a workaround for app_factory to use environment variable instead, but I think Config should accept something like factory_args to be used by self.loaded_app() .
I am up for opening a PR for this matter if this gets confirmed as an issue !
Also, this is my first time raising an issue, so any feedback would be much appreciated :)
p.s) I did find a similar discussion page (#1644) but I don't think the link in the comment correctly addresses this problem
Beta Was this translation helpful? Give feedback.
All reactions