gunicorn icon indicating copy to clipboard operation
gunicorn copied to clipboard

Gunicorn not running pre_request, post_request when using uvicorn worker

Open ahmedbilal opened this issue 3 years ago • 6 comments

ahmedbilal avatar Jan 18 '22 13:01 ahmedbilal

When pre/post request hooks were added, looks like they were added to sync.py and async.py and not the base worker code ... in 0d67447d198bea8521718ef4265128270d1f5476 (some refactoring since). Not sure whether config should be in common base or not ... but it looks like the Uvicorn worker is subclassing the base worker, so missing this functionality.

What's the fix here - make the Uvicorn worker subclass one of the workers with pre_request support, or refactor in Gunicorn to push this config down into base?

javabrett avatar Jan 20 '22 05:01 javabrett

i have the same question asgi pre_request post_request no working

ItisDL avatar Aug 22 '22 12:08 ItisDL

When pre/post request hooks were added, looks like they were added to sync.py and async.py and not the base worker code ... in 0d67447 (some refactoring since). Not sure whether config should be in common base or not ... but it looks like the Uvicorn worker is subclassing the base worker, so missing this functionality.

What's the fix here - make the Uvicorn worker subclass one of the workers with pre_request support, or refactor in Gunicorn to push this config down into base?

you maybe have used work-class,under these circumstances,the logs are placed at the lower for processing;for example,i work gunicorn+uvicorn,when i set work-class ,log-class not work; I hope to help you;

ItisDL avatar Aug 25 '22 08:08 ItisDL

sorry I missed that ticket. I think the intention of this hooks is to ensure this is handled at the right time thois is why it ha s not been included in base_ class. Maybe we should revisit it that would make the writing of a worker easier?

benoitc avatar Aug 25 '22 12:08 benoitc

Is it resolved yet? Because I believe I am facing the same issue here #3114

ArijitSinghEDA avatar Dec 15 '23 08:12 ArijitSinghEDA

Same problem here.

hongquan-hoang-tpv-mti avatar Apr 29 '24 11:04 hongquan-hoang-tpv-mti