diff --git a/src/backend/langflow/__main__.py b/src/backend/langflow/__main__.py index b04cbbd18..dfc2e27a5 100644 --- a/src/backend/langflow/__main__.py +++ b/src/backend/langflow/__main__.py @@ -52,6 +52,18 @@ def display_results(results): console.print() # Print a new line +def set_var_for_macos_issue(): + # OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES + # we need to set this var is we are running on MacOS + # otherwise we get an error when running gunicorn + + if platform.system() in ["Darwin"]: + import os + + os.environ["OBJC_DISABLE_INITIALIZE_FORK_SAFETY"] = "YES" + logger.debug("Set OBJC_DISABLE_INITIALIZE_FORK_SAFETY to YES to avoid error") + + def update_settings( config: str, cache: Optional[str] = None, @@ -143,7 +155,10 @@ def run( """ Run the Langflow. """ + + set_var_for_macos_issue() # override env variables with .env file + if env_file: load_dotenv(env_file, override=True) @@ -165,7 +180,6 @@ def run( options = { "bind": f"{host}:{port}", "workers": get_number_of_workers(workers), - "worker_class": "uvicorn.workers.UvicornWorker", "timeout": timeout, }