add more fields
This commit is contained in:
parent
a9b7c284e7
commit
b7fdb1dfa8
@ -64,7 +64,7 @@ from reflex.components.core.client_side_routing import (
|
|||||||
)
|
)
|
||||||
from reflex.components.core.upload import Upload, get_upload_dir
|
from reflex.components.core.upload import Upload, get_upload_dir
|
||||||
from reflex.components.radix import themes
|
from reflex.components.radix import themes
|
||||||
from reflex.config import get_config
|
from reflex.config import environment, get_config
|
||||||
from reflex.event import Event, EventHandler, EventSpec, window_alert
|
from reflex.event import Event, EventHandler, EventSpec, window_alert
|
||||||
from reflex.model import Model, get_db_status
|
from reflex.model import Model, get_db_status
|
||||||
from reflex.page import (
|
from reflex.page import (
|
||||||
@ -957,15 +957,16 @@ class App(MiddlewareMixin, LifespanMixin, Base):
|
|||||||
executor = None
|
executor = None
|
||||||
if (
|
if (
|
||||||
platform.system() in ("Linux", "Darwin")
|
platform.system() in ("Linux", "Darwin")
|
||||||
and os.environ.get("REFLEX_COMPILE_PROCESSES") is not None
|
and (number_of_processes := environment.REFLEX_COMPILE_PROCESSES)
|
||||||
|
is not None
|
||||||
):
|
):
|
||||||
executor = concurrent.futures.ProcessPoolExecutor(
|
executor = concurrent.futures.ProcessPoolExecutor(
|
||||||
max_workers=int(os.environ.get("REFLEX_COMPILE_PROCESSES", 0)) or None,
|
max_workers=number_of_processes,
|
||||||
mp_context=multiprocessing.get_context("fork"),
|
mp_context=multiprocessing.get_context("fork"),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
executor = concurrent.futures.ThreadPoolExecutor(
|
executor = concurrent.futures.ThreadPoolExecutor(
|
||||||
max_workers=int(os.environ.get("REFLEX_COMPILE_THREADS", 0)) or None,
|
max_workers=environment.REFLEX_COMPILE_THREADS
|
||||||
)
|
)
|
||||||
|
|
||||||
with executor:
|
with executor:
|
||||||
|
@ -180,6 +180,24 @@ def interpret_boolean_env(value: str) -> bool:
|
|||||||
raise ValueError(f"Invalid boolean value: {value}")
|
raise ValueError(f"Invalid boolean value: {value}")
|
||||||
|
|
||||||
|
|
||||||
|
def interpret_int_env(value: str) -> int:
|
||||||
|
"""Interpret an integer environment variable value.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
value: The environment variable value.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The interpreted value.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
ValueError: If the value is invalid.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
return int(value)
|
||||||
|
except ValueError as ve:
|
||||||
|
raise ValueError(f"Invalid integer value: {value}") from ve
|
||||||
|
|
||||||
|
|
||||||
def interpret_path_env(value: str) -> Path:
|
def interpret_path_env(value: str) -> Path:
|
||||||
"""Interpret a path environment variable value.
|
"""Interpret a path environment variable value.
|
||||||
|
|
||||||
@ -209,10 +227,10 @@ def interpret_env_var_value(value: str, field: dataclasses.Field) -> Any:
|
|||||||
|
|
||||||
if field_type is bool:
|
if field_type is bool:
|
||||||
return interpret_boolean_env(value)
|
return interpret_boolean_env(value)
|
||||||
|
|
||||||
elif field_type is str:
|
elif field_type is str:
|
||||||
return value
|
return value
|
||||||
|
elif field_type is int:
|
||||||
|
return interpret_int_env(value)
|
||||||
elif field_type is Path:
|
elif field_type is Path:
|
||||||
return interpret_path_env(value)
|
return interpret_path_env(value)
|
||||||
|
|
||||||
@ -259,6 +277,12 @@ class EnvironmentVariables:
|
|||||||
# The directory to store uploaded files.
|
# The directory to store uploaded files.
|
||||||
REFLEX_UPLOADED_FILES_DIR: Path = Path(constants.Dirs.UPLOADED_FILES)
|
REFLEX_UPLOADED_FILES_DIR: Path = Path(constants.Dirs.UPLOADED_FILES)
|
||||||
|
|
||||||
|
# Whether to use seperate processes to compile the frontend and how many. If not set, defaults to thread executor.
|
||||||
|
REFLEX_COMPILE_PROCESSES: Optional[int] = None
|
||||||
|
|
||||||
|
# Whether to use seperate threads to compile the frontend and how many. Defaults to `min(32, os.cpu_count() + 4)`.
|
||||||
|
REFLEX_COMPILE_THREADS: Optional[int] = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initialize the environment variables."""
|
"""Initialize the environment variables."""
|
||||||
type_hints = get_type_hints(type(self))
|
type_hints = get_type_hints(type(self))
|
||||||
|
Loading…
Reference in New Issue
Block a user