2929
3030class BaseGunicornApplication (gunicorn .app .base .BaseApplication ):
3131 """Base Gunicorn application with common configuration."""
32+
3233 def __init__ (self , app , host , port , debug , ** options ):
3334 global TIMEOUT_SECONDS
3435 TIMEOUT_SECONDS = int (os .environ .get ("CLOUD_RUN_TIMEOUT_SECONDS" , 0 ))
@@ -56,12 +57,13 @@ def load(self):
5657
5758class GunicornApplication (BaseGunicornApplication ):
5859 """Gunicorn application for WSGI apps with gthread worker support."""
60+
5961 def __init__ (self , app , host , port , debug , ** options ):
6062 threads = int (os .environ .get ("THREADS" , (os .cpu_count () or 1 ) * 4 ))
6163 options ["threads" ] = threads
62-
64+
6365 super ().__init__ (app , host , port , debug , ** options )
64-
66+
6567 # Use custom worker with timeout support if conditions are met
6668 if (
6769 TIMEOUT_SECONDS > 0
@@ -83,7 +85,8 @@ def handle_request(self, req, conn):
8385
8486class UvicornApplication (BaseGunicornApplication ):
8587 """Gunicorn application for ASGI apps using Uvicorn workers."""
88+
8689 def __init__ (self , app , host , port , debug , ** options ):
8790 super ().__init__ (app , host , port , debug , ** options )
88-
91+
8992 self .options ["worker_class" ] = "uvicorn_worker.UvicornWorker"
0 commit comments