|
48 | 48 | from pathlib import Path
|
49 | 49 | pio.renderers.default = 'sphinx_gallery'
|
50 | 50 |
|
| 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 | + |
51 | 81 | try:
|
52 | 82 | import torchvision
|
53 | 83 | except ImportError:
|
@@ -114,7 +144,6 @@ def reset_seeds(gallery_conf, fname):
|
114 | 144 | 'pypandoc': {'extra_args': ['--mathjax', '--toc'],
|
115 | 145 | 'filters': ['.jenkins/custom_pandoc_filter.py'],
|
116 | 146 | },
|
117 |
| - 'parallel': 3, |
118 | 147 | }
|
119 | 148 |
|
120 | 149 | html_baseurl = 'https://pytorch.org/tutorials/' # needed for sphinx-sitemap
|
|
0 commit comments