app: recognize REFLEX_COMPILE_PROCESSES and REFLEX_COMPILE_THREADS
Control whether multiprocessing is used and the number of processes or threads that should be used. This will allow users to opt-in to the new, potentially hazardous, multiprocessing mode, which results in much faster compiles, but has already been reverted 4 times. Lets leave the code in this time, but use the thread pool executor by default. Limiting the number of threads or processes to 1 can also aid in debugging issues that arise during compile time.
This commit is contained in:
parent
38eb84498b
commit
5600bc5a30
@ -860,12 +860,17 @@ class App(Base):
|
||||
# Use a forking process pool, if possible. Much faster, especially for large sites.
|
||||
# Fallback to ThreadPoolExecutor as something that will always work.
|
||||
executor = None
|
||||
if platform.system() in ("Linux", "Darwin"):
|
||||
if platform.system() in ("Linux", "Darwin") and os.environ.get(
|
||||
"REFLEX_COMPILE_PROCESSES"
|
||||
):
|
||||
executor = concurrent.futures.ProcessPoolExecutor(
|
||||
mp_context=multiprocessing.get_context("fork")
|
||||
max_workers=int(os.environ.get("REFLEX_COMPILE_PROCESSES", 0)) or None,
|
||||
mp_context=multiprocessing.get_context("fork"),
|
||||
)
|
||||
else:
|
||||
executor = concurrent.futures.ThreadPoolExecutor()
|
||||
executor = concurrent.futures.ThreadPoolExecutor(
|
||||
max_workers=int(os.environ.get("REFLEX_COMPILE_THREADS", 0)) or None,
|
||||
)
|
||||
|
||||
with executor:
|
||||
result_futures = []
|
||||
|
Loading…
Reference in New Issue
Block a user