瀏覽代碼

do not prematurely import app module if providing app_module_import (#5350)

* do not prematurely import app module if providing app_module_import

* use .module
Khaleel Al-Adhami 2 天之前
父節點
當前提交
ff3343a83f
共有 2 個文件被更改,包括 5 次插入5 次删除
  1. 2 2
      reflex/config.py
  2. 3 3
      reflex/utils/exec.py

+ 2 - 2
reflex/config.py

@@ -1006,8 +1006,8 @@ If you are not using tailwind, set `tailwind` to `None` in rxconfig.py.""",
         Returns:
             The module name.
         """
-        if self.app_module is not None:
-            return self.app_module.__name__
+        if self.app_module_import is not None:
+            return self.app_module_import
         return ".".join([self.app_name, self.app_name])
 
     def update_from_env(self) -> dict[str, Any]:

+ 3 - 3
reflex/utils/exec.py

@@ -300,9 +300,9 @@ def get_reload_paths() -> Sequence[Path]:
         The reload paths for the backend.
     """
     config = get_config()
-    reload_paths = [Path(config.app_name).parent]
-    if config.app_module is not None and config.app_module.__file__:
-        module_path = Path(config.app_module.__file__).resolve().parent
+    reload_paths = [Path.cwd()]
+    if (spec := importlib.util.find_spec(config.module)) is not None and spec.origin:
+        module_path = Path(spec.origin).resolve().parent
 
         while module_path.parent.name and any(
             sibling_file.name == "__init__.py"