MCPcopy Create free account
hub / github.com/pytorch/tutorials / call_in_subprocess

Function call_in_subprocess

conf.py:79–93  ·  view source on GitHub ↗
(func)

Source from the content-addressed store, hash-verified

77
78
79def call_in_subprocess(func):
80 def wrapper(*args, **kwargs):
81 result_queue = multiprocessing.Queue()
82 p = multiprocessing.Process(
83 target=call_fn, 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
93 return wrapper
94
95
96# Windows does not support multiprocessing with fork and mac has issues with

Callers 1

conf.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected