Sfoglia il codice sorgente

(dev mode) start backend without waiting for page compilation (#2549)

* start backend without waiting for page compilation

* remove prints for measuring time saved

* pin tighter on uvicorn
jackie-pc 1 anno fa
parent
commit
a4c8c72177
3 ha cambiato i file con 437 aggiunte e 398 eliminazioni
  1. 426 392
      poetry.lock
  2. 1 4
      pyproject.toml
  3. 10 2
      reflex/app_module_for_backend.py

File diff suppressed because it is too large
+ 426 - 392
poetry.lock


+ 1 - 4
pyproject.toml

@@ -40,10 +40,7 @@ redis = "^4.3.5"
 rich = "^13.0.0"
 sqlmodel = "^0.0.14"
 typer = ">=0.4.2,<1"
-uvicorn = [
-    {version = "^0.24.0", python = ">=3.12"},
-    {version = "^0.20.0", python = "<3.12"},
-]
+uvicorn = "^0.27.0"
 watchdog = "^2.3.1"
 watchfiles = "^0.19.0"
 starlette-admin = "^0.9.0"

+ 10 - 2
reflex/app_module_for_backend.py

@@ -1,13 +1,21 @@
 """Shims the real reflex app module for running backend server (uvicorn or gunicorn).
 Only the app attribute is explicitly exposed.
 """
+from concurrent.futures import ThreadPoolExecutor
+
 from reflex import constants
-from reflex.utils.prerequisites import get_compiled_app
+from reflex.utils.prerequisites import get_app, get_compiled_app
 
 if "app" != constants.CompileVars.APP:
     raise AssertionError("unexpected variable name for 'app'")
-app = getattr(get_compiled_app(), constants.CompileVars.APP)
+
+app_module = get_app(reload=False)
+app = getattr(app_module, constants.CompileVars.APP)
+ThreadPoolExecutor(max_workers=1).submit(app.compile_)
 
 # ensure only "app" is exposed.
+del app_module
+del get_app
 del get_compiled_app
 del constants
+del ThreadPoolExecutor

Some files were not shown because too many files changed in this diff