Skip to content

fix(google_ai): close aiohttp session to prevent ResourceWarning#2629

Open
raymondWai wants to merge 3 commits intodeepset-ai:mainfrom
raymondWai:fix-unclosed-session-google-ai
Open

fix(google_ai): close aiohttp session to prevent ResourceWarning#2629
raymondWai wants to merge 3 commits intodeepset-ai:mainfrom
raymondWai:fix-unclosed-session-google-ai

Conversation

@raymondWai
Copy link

Related Issues

Proposed Changes:

When I try to use GoogleGenAIChatGenerator in a AsyncPipeline, It always show Unclosed client session error.

What I do to fix it is adding self._client.aio.aclose() to the finally clause to run_async function

How did you test it?

Run pytest integrations/google_genai/tests/

Checklist

@raymondWai raymondWai requested a review from a team as a code owner December 27, 2025 03:24
@raymondWai raymondWai requested review from vblagoje and removed request for a team December 27, 2025 03:24
@CLAassistant
Copy link

CLAassistant commented Dec 27, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@vblagoje vblagoje left a comment

Choose a reason for hiding this comment

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

Thanks for the contrib but I don't think this is the right approach. The fix should close the session when the component is destroyed, not after each run_async call. The _client is stored as self._client (instance variable) and not created fresh each time.

@github-actions github-actions bot added the type:documentation Improvements or additions to documentation label Jan 3, 2026
@raymondWai
Copy link
Author

Just moved the close method call to destructor and exit

@raymondWai raymondWai requested a review from vblagoje January 3, 2026 05:39
@anakin87 anakin87 self-requested a review March 10, 2026 15:58
Copy link
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

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

Sorry for the delay.

Could you please rebase your branch or merge main? There are some conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:google-genai type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Uncloused Client Error trigger when use GoogleGenAIChatGenerator in a AsyncPipeline

4 participants