fix: bugs-01
This commit is contained in:
@@ -24,6 +24,24 @@ def process_image_ocr(self, image_id: str):
|
||||
_run_async(process_image_ocr_async(image_id))
|
||||
|
||||
|
||||
async def process_images_ocr_batch_async(image_ids: list[str], max_concurrency: int) -> None:
|
||||
"""Process many images with bounded OCR concurrency."""
|
||||
if not image_ids:
|
||||
return
|
||||
concurrency = max(1, max_concurrency)
|
||||
semaphore = asyncio.Semaphore(concurrency)
|
||||
|
||||
async def _run_one(image_id: str) -> None:
|
||||
async with semaphore:
|
||||
try:
|
||||
await process_image_ocr_async(image_id)
|
||||
except Exception:
|
||||
# Keep batch processing alive even if one image fails.
|
||||
logger.exception("Image %s OCR failed in batch", image_id)
|
||||
|
||||
await asyncio.gather(*[_run_one(image_id) for image_id in image_ids])
|
||||
|
||||
|
||||
async def process_image_ocr_async(image_id_str: str):
|
||||
from app.core.database import async_session_factory
|
||||
from sqlalchemy import delete
|
||||
|
||||
Reference in New Issue
Block a user