소스 검색

(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 년 전
부모
커밋
a4c8c72177
3개의 변경된 파일437개의 추가작업 그리고 398개의 파일을 삭제
  1. 426 392
      poetry.lock
  2. 1 4
      pyproject.toml
  3. 10 2
      reflex/app_module_for_backend.py

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 426 - 392
poetry.lock


+ 1 - 4
pyproject.toml

@@ -40,10 +40,7 @@ redis = "^4.3.5"
 rich = "^13.0.0"
 rich = "^13.0.0"
 sqlmodel = "^0.0.14"
 sqlmodel = "^0.0.14"
 typer = ">=0.4.2,<1"
 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"
 watchdog = "^2.3.1"
 watchfiles = "^0.19.0"
 watchfiles = "^0.19.0"
 starlette-admin = "^0.9.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).
 """Shims the real reflex app module for running backend server (uvicorn or gunicorn).
 Only the app attribute is explicitly exposed.
 Only the app attribute is explicitly exposed.
 """
 """
+from concurrent.futures import ThreadPoolExecutor
+
 from reflex import constants
 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:
 if "app" != constants.CompileVars.APP:
     raise AssertionError("unexpected variable name for '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.
 # ensure only "app" is exposed.
+del app_module
+del get_app
 del get_compiled_app
 del get_compiled_app
 del constants
 del constants
+del ThreadPoolExecutor

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.