diff --git a/reflex/app.py b/reflex/app.py index c123d557a..d7c0786f8 100644 --- a/reflex/app.py +++ b/reflex/app.py @@ -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 = []