mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-05-16 10:07:36 -03:00
fix(recipes): offload EXIF to thread pool, throttle concurrent imports, eliminate duplicate Civitai API call
- Wrap ExifUtils.extract_image_metadata() with asyncio.to_thread() in both import handlers and analysis_service to prevent Pillow/piexif from blocking ComfyUI's event loop during batch imports. - Add asyncio.Semaphore(2) to import_remote_recipe and import_from_url endpoints to cap concurrent heavy work and prevent event loop starvation. - Pre-fetch Civitai image_info during download and pass it to the recipe enricher, eliminating a redundant get_image_info() API round-trip.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import base64
|
||||
import io
|
||||
import os
|
||||
@@ -170,7 +171,9 @@ class RecipeAnalysisService:
|
||||
await self._download_image(url, temp_path)
|
||||
|
||||
if metadata is None and not is_video:
|
||||
metadata = self._exif_utils.extract_image_metadata(temp_path)
|
||||
metadata = await asyncio.to_thread(
|
||||
self._exif_utils.extract_image_metadata, temp_path
|
||||
)
|
||||
|
||||
return await self._parse_metadata(
|
||||
metadata or {},
|
||||
@@ -199,7 +202,9 @@ class RecipeAnalysisService:
|
||||
if not os.path.isfile(normalized_path):
|
||||
raise RecipeNotFoundError("File not found")
|
||||
|
||||
metadata = self._exif_utils.extract_image_metadata(normalized_path)
|
||||
metadata = await asyncio.to_thread(
|
||||
self._exif_utils.extract_image_metadata, normalized_path
|
||||
)
|
||||
if not metadata:
|
||||
return self._metadata_not_found_response(normalized_path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user