Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions reflex/reflex.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,29 +211,32 @@ def _run(

prerequisites.check_latest_package_version(constants.Reflex.MODULE_NAME)

# Get the app module.
app_task = prerequisites.compile_or_validate_app
args = (frontend,)
kwargs = {
"check_if_schema_up_to_date": True,
"prerender_routes": exec.should_prerender_routes(),
}

# Granian fails if the app is already imported.
if should_use_granian():
import concurrent.futures

compile_future = concurrent.futures.ProcessPoolExecutor(max_workers=1).submit(
app_task,
*args,
**kwargs,
)
return_result = compile_future.result()
else:
return_result = app_task(*args, **kwargs)
if frontend:
# Get the app module.
app_task = prerequisites.compile_or_validate_app
args = (frontend,)
kwargs = {
"check_if_schema_up_to_date": True,
"prerender_routes": exec.should_prerender_routes(),
}

# Granian fails if the app is already imported.
if should_use_granian():
import concurrent.futures

compile_future = concurrent.futures.ProcessPoolExecutor(
max_workers=1
).submit(
app_task,
*args,
**kwargs,
)
return_result = compile_future.result()
else:
return_result = app_task(*args, **kwargs)

if not return_result:
raise SystemExit(1)
if not return_result:
raise SystemExit(1)

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