From bd188e59c876761561d025142800798dec94c7bf Mon Sep 17 00:00:00 2001 From: Radomir Stevanovic Date: Thu, 27 Jun 2024 05:30:17 -0700 Subject: [PATCH] Use `spawn` instead of `fork` method for Dash callbacks See: https://bugs.python.org/issue33725. --- app.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app.py b/app.py index e73cf13..4066a77 100644 --- a/app.py +++ b/app.py @@ -46,6 +46,17 @@ cache = diskcache.Cache("./cache") background_callback_manager = DiskcacheManager(cache) +# Fix Dash long callbacks crashing on macOS 10.13+ (also potentially not working +# on other POSIX systems), caused by https://bugs.python.org/issue33725 +# (aka "beware of multithreaded process forking"). +# +# Note: default start method has already been changed to "spawn" on darwin in +# the `multiprocessing` library, but its fork, `multiprocess` still hasn't caught up. +# (see docs: https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods) +import multiprocess +if multiprocess.get_start_method(allow_none=True) is None: + multiprocess.set_start_method('spawn') + from app_configs import ( APP_TITLE, CLASSICAL_TAB_LABEL,