From e72c04a94ad82bd88afb568ae4cecbf6c0ab61a6 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 4 Oct 2023 12:48:30 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(=5F=5Fmain=5F=5F.py):=20set?= =?UTF-8?q?=20OBJC=5FDISABLE=5FINITIALIZE=5FFORK=5FSAFETY=20environment=20?= =?UTF-8?q?variable=20on=20MacOS=20to=20avoid=20error=20when=20running=20g?= =?UTF-8?q?unicorn=20=E2=9C=A8=20feat(=5F=5Fmain=5F=5F.py):=20load=20envir?= =?UTF-8?q?onment=20variables=20from=20.env=20file=20to=20override=20exist?= =?UTF-8?q?ing=20environment=20variables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/__main__.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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, }