Skip to content

Commit 9d45f12

Browse files
committed
tc
1 parent 43704cb commit 9d45f12

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

conf.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,36 @@
4848
from pathlib import Path
4949
pio.renderers.default = 'sphinx_gallery'
5050

51+
import sphinx_gallery.gen_rst
52+
import multiprocessing
53+
54+
# Save the original function
55+
def isolated_call(func, args, kwargs, result_queue):
56+
try:
57+
result = func(*args, **kwargs)
58+
result_queue.put((True, result))
59+
except Exception as e:
60+
result_queue.put((False, str(e)))
61+
62+
def make_isolated_version(func):
63+
def wrapper(*args, **kwargs):
64+
result_queue = multiprocessing.Queue()
65+
p = multiprocessing.Process(
66+
target=isolated_call,
67+
args=(func, args, kwargs, result_queue)
68+
)
69+
p.start()
70+
p.join()
71+
success, result = result_queue.get()
72+
if success:
73+
return result
74+
else:
75+
raise RuntimeError(f"Error in isolated process: {result}")
76+
return wrapper
77+
78+
# Monkey-patch
79+
sphinx_gallery.gen_rst.generate_file_rst = make_isolated_version(sphinx_gallery.gen_rst.generate_file_rst)
80+
5181
try:
5282
import torchvision
5383
except ImportError:
@@ -114,7 +144,6 @@ def reset_seeds(gallery_conf, fname):
114144
'pypandoc': {'extra_args': ['--mathjax', '--toc'],
115145
'filters': ['.jenkins/custom_pandoc_filter.py'],
116146
},
117-
'parallel': 3,
118147
}
119148

120149
html_baseurl = 'https://pytorch.org/tutorials/' # needed for sphinx-sitemap

0 commit comments

Comments
 (0)