add try except
This commit is contained in:
parent
e0a8e8dedc
commit
6b4e030328
@ -825,6 +825,17 @@ def get_config(reload: bool = False) -> Config:
|
||||
return Config(app_name="")
|
||||
rxconfig = importlib.import_module(constants.Config.MODULE)
|
||||
return rxconfig.config
|
||||
except Exception:
|
||||
sys.path.extend(sys_path)
|
||||
# only import the module if it exists. If a module spec exists then
|
||||
# the module exists.
|
||||
spec = find_spec(constants.Config.MODULE)
|
||||
if not spec:
|
||||
# we need this condition to ensure that a ModuleNotFound error is not thrown when
|
||||
# running unit/integration tests or during `reflex init`.
|
||||
return Config(app_name="")
|
||||
rxconfig = importlib.import_module(constants.Config.MODULE)
|
||||
return rxconfig.config
|
||||
finally:
|
||||
sys.path.clear()
|
||||
sys.path.extend(sys_path)
|
||||
|
Loading…
Reference in New Issue
Block a user