From 74002b32e7277ec4fad70c61539ad9490407c934 Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Tue, 8 Jul 2025 18:35:38 -0700 Subject: [PATCH 1/2] tc --- conf.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/conf.py b/conf.py index 7401bdcea2..c9a588f7f7 100644 --- a/conf.py +++ b/conf.py @@ -71,6 +71,7 @@ def call_fn(func, args, kwargs, result_queue): def call_in_subprocess(func): def wrapper(*args, **kwargs): + multiprocessing.set_start_method("fork", force=True) result_queue = multiprocessing.Queue() p = multiprocessing.Process( target=call_fn, @@ -85,7 +86,10 @@ def wrapper(*args, **kwargs): raise RuntimeError(f"Error in subprocess: {result}") return wrapper -sphinx_gallery.gen_rst.generate_file_rst = call_in_subprocess(sphinx_gallery.gen_rst.generate_file_rst) +# Windows does not support multiprocessing with fork, so we do not monkey patch +# sphinx gallery to run in subprocesses. +if os.getenv("TUTORIALS_ISOLATE_BUILD", "1") == "1" and not sys.platform.startswith("win"): + sphinx_gallery.gen_rst.generate_file_rst = call_in_subprocess(sphinx_gallery.gen_rst.generate_file_rst) try: import torchvision From 91e170534ca763b8b03122d1c244f48535e7fada Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Wed, 9 Jul 2025 13:54:44 -0700 Subject: [PATCH 2/2] tc --- conf.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/conf.py b/conf.py index c9a588f7f7..1011fca60c 100644 --- a/conf.py +++ b/conf.py @@ -71,7 +71,6 @@ def call_fn(func, args, kwargs, result_queue): def call_in_subprocess(func): def wrapper(*args, **kwargs): - multiprocessing.set_start_method("fork", force=True) result_queue = multiprocessing.Queue() p = multiprocessing.Process( target=call_fn, @@ -86,9 +85,9 @@ def wrapper(*args, **kwargs): raise RuntimeError(f"Error in subprocess: {result}") return wrapper -# Windows does not support multiprocessing with fork, so we do not monkey patch -# sphinx gallery to run in subprocesses. -if os.getenv("TUTORIALS_ISOLATE_BUILD", "1") == "1" and not sys.platform.startswith("win"): +# Windows does not support multiprocessing with fork and mac has issues with +# fork so we do not monkey patch sphinx gallery to run in subprocesses. +if os.getenv("TUTORIALS_ISOLATE_BUILD", "1") == "1" and not sys.platform.startswith("win") and not sys.platform == "darwin": sphinx_gallery.gen_rst.generate_file_rst = call_in_subprocess(sphinx_gallery.gen_rst.generate_file_rst) try: