mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-01-31 23:55:06 +08:00
Refa: asyncio.to_thread to ThreadPoolExecutor to break thread limitat… (#12716)
### Type of change - [x] Refactoring
This commit is contained in:
@ -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():
|
||||
|
||||
Reference in New Issue
Block a user