MCPcopy
hub / github.com/modelscope/ms-swift / thread_run

Method thread_run

swift/infer_engine/infer_engine.py:264–280  ·  view source on GitHub ↗
(target, args=(), kwargs=None)

Source from the content-addressed store, hash-verified

262
263 @staticmethod
264 def thread_run(target, args=(), kwargs=None):
265 kwargs = kwargs or {}
266
267 def func(target, queue, args, kwargs):
268 try:
269 queue.put(target(*args, **kwargs))
270 except Exception as e:
271 queue.put(e)
272
273 queue = Queue()
274 thread = Thread(target=func, args=(target, queue, args, kwargs))
275 thread.start()
276 thread.join()
277 result = queue.get()
278 if isinstance(result, Exception):
279 raise result
280 return result
281
282 @staticmethod
283 def safe_asyncio_run(coro):

Callers 1

safe_asyncio_runMethod · 0.80

Calls 1

startMethod · 0.80

Tested by

no test coverage detected