@@ -189,9 +189,11 @@ def run_frontend_prod(root: Path, port: str, backend_present: bool = True):
189
189
190
190
@once
191
191
def _warn_user_about_uvicorn ():
192
- console .warn (
193
- "Using Uvicorn for backend as it is installed. This behavior will change in 0.8.0 to use Granian by default."
194
- )
192
+ # When we eventually switch to Granian by default, we should enable this warning.
193
+ if False :
194
+ console .warn (
195
+ "Using Uvicorn for backend as it is installed. This behavior will change in 0.8.0 to use Granian by default."
196
+ )
195
197
196
198
197
199
def should_use_granian ():
@@ -357,70 +359,74 @@ def run_granian_backend(host: str, port: int, loglevel: LogLevel):
357
359
).serve ()
358
360
359
361
362
+ def _deprecate_asgi_config (
363
+ config_name : str ,
364
+ reason : str = "" ,
365
+ ):
366
+ # When we eventually switch to Granian by default, we should enable this deprecation.
367
+ if False :
368
+ console .deprecate (
369
+ f"config.{ config_name } " ,
370
+ reason = reason ,
371
+ deprecation_version = "0.7.5" ,
372
+ removal_version = "0.8.0" ,
373
+ )
374
+
375
+
360
376
@once
361
377
def _get_backend_workers ():
362
378
from reflex .utils import processes
363
379
364
380
config = get_config ()
365
381
382
+ gunicorn_workers = config .gunicorn_workers or 0
383
+
366
384
if config .gunicorn_workers is not None :
367
- console .deprecate (
368
- "config.gunicorn_workers" ,
369
- reason = "If you're using Granian, use GRANIAN_WORKERS instead." ,
370
- deprecation_version = "0.7.4" ,
371
- removal_version = "0.8.0" ,
385
+ _deprecate_asgi_config (
386
+ "gunicorn_workers" ,
387
+ "If you're using Granian, use GRANIAN_WORKERS instead." ,
372
388
)
373
389
374
- return (
375
- processes .get_num_workers ()
376
- if not config .gunicorn_workers
377
- else config .gunicorn_workers
378
- )
390
+ return gunicorn_workers if gunicorn_workers else processes .get_num_workers ()
379
391
380
392
381
393
@once
382
394
def _get_backend_timeout ():
383
395
config = get_config ()
384
396
397
+ timeout = config .timeout or 120
398
+
385
399
if config .timeout is not None :
386
- console .deprecate (
387
- "config.timeout" ,
388
- reason = "If you're using Granian, use GRANIAN_WORKERS_LIFETIME instead." ,
389
- deprecation_version = "0.7.4" ,
390
- removal_version = "0.8.0" ,
400
+ _deprecate_asgi_config (
401
+ "timeout" ,
402
+ "If you're using Granian, use GRANIAN_WORKERS_LIFETIME instead." ,
391
403
)
392
404
393
- return config . timeout
405
+ return timeout
394
406
395
407
396
408
@once
397
409
def _get_backend_max_requests ():
398
410
config = get_config ()
399
411
412
+ gunicorn_max_requests = config .gunicorn_max_requests or 120
413
+
400
414
if config .gunicorn_max_requests is not None :
401
- console .deprecate (
402
- "config.gunicorn_max_requests" ,
403
- reason = "" ,
404
- deprecation_version = "0.7.4" ,
405
- removal_version = "0.8.0" ,
406
- )
415
+ _deprecate_asgi_config ("gunicorn_max_requests" )
407
416
408
- return config . gunicorn_max_requests
417
+ return gunicorn_max_requests
409
418
410
419
411
420
@once
412
421
def _get_backend_max_requests_jitter ():
413
422
config = get_config ()
414
423
424
+ gunicorn_max_requests_jitter = config .gunicorn_max_requests_jitter or 25
425
+
415
426
if config .gunicorn_max_requests_jitter is not None :
416
- console .deprecate (
417
- "config.gunicorn_max_requests_jitter" ,
418
- reason = "" ,
419
- deprecation_version = "0.7.4" ,
420
- removal_version = "0.8.0" ,
421
- )
427
+ _deprecate_asgi_config ("gunicorn_max_requests_jitter" )
422
428
423
- return config . gunicorn_max_requests_jitter
429
+ return gunicorn_max_requests_jitter
424
430
425
431
426
432
def run_backend_prod (
0 commit comments