Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions runware/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,20 +595,21 @@ async def _requestImages(
"numberResults": image_remaining,
}

let_lis = await self.listenToImages(
onPartialImages=on_partial_images,
taskUUID=task_uuid,
groupKey=LISTEN_TO_IMAGES_KEY.REQUEST_IMAGES,
)

await self.send([new_request_object])

if new_request_object.get("webhookURL"):
let_lis["destroy"]()
return await self._handleWebhookAcknowledgment(
Comment on lines +598 to 608
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let_lis is now created before await self.send(...), but _requestImages() doesn’t guard this with a try/finally. If send() raises (e.g., connection closing) or if the subsequent wait/processing raises, this listener will remain registered in self._listeners and can accumulate across retries/concurrent calls. Consider wrapping the section from listener creation through response handling in try/finally (or try/except + re-raise) to ensure let_lis["destroy"]() always runs on all exit paths (including send() failures and getSimililarImage() timeouts/exceptions).

Copilot uses AI. Check for mistakes.
task_uuid=task_uuid,
task_type="imageInference",
debug_key="image-inference-webhook"
)

let_lis = await self.listenToImages(
onPartialImages=on_partial_images,
taskUUID=task_uuid,
groupKey=LISTEN_TO_IMAGES_KEY.REQUEST_IMAGES,
)
images = await self.getSimililarImage(
taskUUID=task_uuids,
numberOfImages=number_of_images,
Expand Down