Skip to content

Commit 9531038

Browse files
authored
Fix/google blocking (#104)
* Set shell to bash in makefile * Run Nano Banana sync b64 extract/resize in thread
1 parent a3c5c2e commit 9531038

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

griptape_nodes_library/image/google_image_generation.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import asyncio
34
import base64
45
import json
56
import logging
@@ -664,7 +665,11 @@ async def _process_input_image(self, image_input: Any, *, auto_image_resize: boo
664665
logger.debug("%s failed to load image value: %s", self.name, image_value)
665666
return None
666667

667-
return self._extract_mime_and_base64_from_data_uri(data_uri, auto_image_resize=auto_image_resize)
668+
# Run CPU-bound base64 decode + PIL image resizing in a thread pool
669+
# to avoid blocking the event loop for large images.
670+
return await asyncio.to_thread(
671+
self._extract_mime_and_base64_from_data_uri, data_uri, auto_image_resize=auto_image_resize
672+
)
668673

669674
def _extract_mime_and_base64_from_data_uri(
670675
self, data_uri: str, *, auto_image_resize: bool = True

0 commit comments

Comments
 (0)