gunicorn icon indicating copy to clipboard operation
gunicorn copied to clipboard

worker-class parameter accepts class additionally to class path

Open odyfatouros opened this issue 2 years ago • 3 comments

I have a FastAPI application running on gunicorn with the use of uvicorn workers. I am creating my own custom uvicorn worker because i need to pass specific config parameters to uvicorn that are managed by a central config.yml file by application managers. What i want to do is pass the defined class to the "worker-class" parameter of the gunicorn config and not the class path. This would allow me to define my class inside the function that calls the gunicorn application and also has access to all config parameters.

After investigating the code i found out that actually the util.load_class function has the possibility to distinguish between class and class path (which is str) and return the class. The problem lies in the config module and the properties "worker_class" and "worker_class_str". A simple check about the type of the uri would be enough for the application to start properly with the given class.

odyfatouros avatar Oct 13 '23 11:10 odyfatouros

i created a pull request with a fix for this issue and would appreciate it if you guys could have a look.

odyfatouros avatar Oct 13 '23 14:10 odyfatouros

It looks like you created a branch but I don't see a PR. Can you open a PR and I can take a look, please?

tilgovi avatar Dec 29 '23 05:12 tilgovi

Oh, I'm sorry, I found it at #3079.

tilgovi avatar Dec 29 '23 05:12 tilgovi

i don't see any pull request there... did you close it?

benoitc avatar Aug 06 '24 19:08 benoitc

No i didn't. I already got one review and I think I need one more in order for the PR to be merged. I didn't change anything.

Benoit Chesneau @.***> schrieb am Di., 6. Aug. 2024, 22:42:

i don't see any pull request there... did you close it?

— Reply to this email directly, view it on GitHub https://github.com/benoitc/gunicorn/issues/3079#issuecomment-2272017943, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSC4O447QSNUYJDBDRHMHTZQERL3AVCNFSM6AAAAABMC7Q72WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZSGAYTOOJUGM . You are receiving this because you authored the thread.Message ID: @.***>

odyfatouros avatar Aug 06 '24 19:08 odyfatouros

@odyfatouros i only see code in your repo. Can you point me to the PR?

benoitc avatar Aug 06 '24 22:08 benoitc

Here it is https://github.com/benoitc/gunicorn/pull/3080

Benoit Chesneau @.***> schrieb am Mi., 7. Aug. 2024, 01:33:

@odyfatouros https://github.com/odyfatouros i only see code in your repo. Can you point me to the PR?

— Reply to this email directly, view it on GitHub https://github.com/benoitc/gunicorn/issues/3079#issuecomment-2272262543, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSC4O3WSSCLDH4VL7YDQYTZQFFKRAVCNFSM6AAAAABMC7Q72WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZSGI3DENJUGM . You are receiving this because you were mentioned.Message ID: @.***>

odyfatouros avatar Aug 07 '24 03:08 odyfatouros

applied thanks.

benoitc avatar Aug 07 '24 06:08 benoitc