Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 08e081b

Browse files
adhami3310bhatia2akshit
authored andcommittedMar 24, 2025
move granian to the sidelines (reflex-dev#5010)
* move granian to the sidelines * what * oops as well
1 parent faa47ed commit 08e081b

File tree

4 files changed

+59
-38
lines changed

4 files changed

+59
-38
lines changed
 

‎pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ dependencies = [
2626
"distro >=1.8.0,<2.0; platform_system == 'Linux'",
2727
"fastapi >=0.96.0,!=0.111.0,!=0.111.1",
2828
"granian[reload] >=2.0.0",
29+
"gunicorn >=23.0.0,<24.0.0",
2930
"httpx >=0.25.1,<1.0",
3031
"jinja2 >=3.1.2,<4.0",
3132
"lazy_loader >=0.4",
@@ -46,6 +47,7 @@ dependencies = [
4647
"twine >=4.0.0,<7.0",
4748
"typer >=0.15.1,<1.0",
4849
"typing_extensions >=4.6.0",
50+
"uvicorn >=0.20.0",
4951
"wheel >=0.42.0,<1.0",
5052
"wrapt >=1.17.0,<2.0",
5153
]
@@ -161,5 +163,4 @@ dev = [
161163
"ruff ==0.11.0",
162164
"selenium >=4.11.0,<5.0",
163165
"toml >=0.10.2,<1.0",
164-
"uvicorn >=0.20.0",
165166
]

‎reflex/app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ def _should_compile(self) -> bool:
998998
# Check the nocompile file.
999999
if nocompile.exists():
10001000
# Delete the nocompile file
1001-
nocompile.unlink()
1001+
nocompile.unlink(missing_ok=True)
10021002
return False
10031003

10041004
# By default, compile the app.

‎reflex/utils/exec.py

+39-33
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,11 @@ def run_frontend_prod(root: Path, port: str, backend_present: bool = True):
189189

190190
@once
191191
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+
)
195197

196198

197199
def should_use_granian():
@@ -357,70 +359,74 @@ def run_granian_backend(host: str, port: int, loglevel: LogLevel):
357359
).serve()
358360

359361

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+
360376
@once
361377
def _get_backend_workers():
362378
from reflex.utils import processes
363379

364380
config = get_config()
365381

382+
gunicorn_workers = config.gunicorn_workers or 0
383+
366384
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.",
372388
)
373389

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()
379391

380392

381393
@once
382394
def _get_backend_timeout():
383395
config = get_config()
384396

397+
timeout = config.timeout or 120
398+
385399
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.",
391403
)
392404

393-
return config.timeout
405+
return timeout
394406

395407

396408
@once
397409
def _get_backend_max_requests():
398410
config = get_config()
399411

412+
gunicorn_max_requests = config.gunicorn_max_requests or 120
413+
400414
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")
407416

408-
return config.gunicorn_max_requests
417+
return gunicorn_max_requests
409418

410419

411420
@once
412421
def _get_backend_max_requests_jitter():
413422
config = get_config()
414423

424+
gunicorn_max_requests_jitter = config.gunicorn_max_requests_jitter or 25
425+
415426
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")
422428

423-
return config.gunicorn_max_requests_jitter
429+
return gunicorn_max_requests_jitter
424430

425431

426432
def run_backend_prod(

‎uv.lock

+17-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.