Skip to content

Commit 06e733a

Browse files
authored
avoid validating app when running in backend only (#6203)
* avoid validating app when running in backend only * precommit
1 parent 64a0bc6 commit 06e733a

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

reflex/reflex.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -211,29 +211,32 @@ def _run(
211211

212212
prerequisites.check_latest_package_version(constants.Reflex.MODULE_NAME)
213213

214-
# Get the app module.
215-
app_task = prerequisites.compile_or_validate_app
216-
args = (frontend,)
217-
kwargs = {
218-
"check_if_schema_up_to_date": True,
219-
"prerender_routes": exec.should_prerender_routes(),
220-
}
221-
222-
# Granian fails if the app is already imported.
223-
if should_use_granian():
224-
import concurrent.futures
225-
226-
compile_future = concurrent.futures.ProcessPoolExecutor(max_workers=1).submit(
227-
app_task,
228-
*args,
229-
**kwargs,
230-
)
231-
return_result = compile_future.result()
232-
else:
233-
return_result = app_task(*args, **kwargs)
214+
if frontend:
215+
# Get the app module.
216+
app_task = prerequisites.compile_or_validate_app
217+
args = (frontend,)
218+
kwargs = {
219+
"check_if_schema_up_to_date": True,
220+
"prerender_routes": exec.should_prerender_routes(),
221+
}
222+
223+
# Granian fails if the app is already imported.
224+
if should_use_granian():
225+
import concurrent.futures
226+
227+
compile_future = concurrent.futures.ProcessPoolExecutor(
228+
max_workers=1
229+
).submit(
230+
app_task,
231+
*args,
232+
**kwargs,
233+
)
234+
return_result = compile_future.result()
235+
else:
236+
return_result = app_task(*args, **kwargs)
234237

235-
if not return_result:
236-
raise SystemExit(1)
238+
if not return_result:
239+
raise SystemExit(1)
237240

238241
if env != constants.Env.PROD and env != constants.Env.DEV:
239242
msg = f"Invalid env: {env}. Must be DEV or PROD."

0 commit comments

Comments
 (0)