Refa: asyncio.to_thread to ThreadPoolExecutor to break thread limitat… (#12716)

### Type of change

- [x] Refactoring
This commit is contained in:
Kevin Hu
2026-01-20 13:29:37 +08:00
committed by GitHub
parent 120648ac81
commit 927db0b373
30 changed files with 246 additions and 157 deletions

View File

@ -18,6 +18,10 @@ import asyncio
import logging
import os
import sys
from common.misc_utils import thread_pool_exec
sys.path.insert(
0,
os.path.abspath(
@ -64,9 +68,9 @@ def main(args):
if limiter:
async with limiter:
print(f"Task {i} use device {id}")
await asyncio.to_thread(__ocr, i, id, img)
await thread_pool_exec(__ocr, i, id, img)
else:
await asyncio.to_thread(__ocr, i, id, img)
await thread_pool_exec(__ocr, i, id, img)
async def __ocr_launcher():