MCPcopy Create free account
hub / github.com/modelscope/FunASR / run_blocking

Function run_blocking

runtime/python/websocket/funasr_wss_server.py:306–316  ·  view source on GitHub ↗

把阻塞函数丢线程池执行,避免卡 event loop。 sem 用于限流(避免 GPU / 模型被打爆)。

(fn, *a, sem: asyncio.Semaphore | None = None, **kw)

Source from the content-addressed store, hash-verified

304
305
306async def run_blocking(fn, *a, sem: asyncio.Semaphore | None = None, **kw):
307 """
308 把阻塞函数丢线程池执行,避免卡 event loop。
309 sem 用于限流(避免 GPU / 模型被打爆)。
310 """
311 loop = asyncio.get_running_loop()
312 call = functools.partial(fn, *a, **kw)
313 if sem is None:
314 return await loop.run_in_executor(EXECUTOR, call)
315 async with sem:
316 return await loop.run_in_executor(EXECUTOR, call)
317
318
319def _generate_sync(model, audio_or_text, status_dict):

Callers 4

ws_serveFunction · 0.85
async_vadFunction · 0.85
async_asrFunction · 0.85
async_asr_onlineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…