File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 68
68
# Alt option 2: Run sphinx gallery once per file (similar to how we shard in CI
69
69
# but with shard sizes of 1), but running sphinx gallery for each file has a
70
70
# ~5min overhead, resulting in the entire suite taking ~2x time
71
+ def call_fn (func , args , kwargs , result_queue ):
72
+ try :
73
+ result = func (* args , ** kwargs )
74
+ result_queue .put ((True , result ))
75
+ except Exception as e :
76
+ result_queue .put ((False , str (e )))
77
+
78
+ def call_in_subprocess (func ):
79
+ def wrapper (* args , ** kwargs ):
80
+ result_queue = multiprocessing .Queue ()
81
+ p = multiprocessing .Process (
82
+ target = call_fn ,
83
+ args = (func , args , kwargs , result_queue )
84
+ )
85
+ p .start ()
86
+ p .join ()
87
+ success , result = result_queue .get ()
88
+ if success :
89
+ return result
90
+ else :
91
+ raise RuntimeError (f"Error in subprocess: { result } " )
92
+ return wrapper
93
+
94
+ sphinx_gallery .gen_rst .generate_file_rst = call_in_subprocess (sphinx_gallery .gen_rst .generate_file_rst )
71
95
72
96
try :
73
97
import torchvision
You can’t perform that action at this time.
0 commit comments