Skip to content
← Back to activity

Public problem

Unclosed client session and Unclosed connector warnings after upgrading to v1.37

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

After upgrading google-genai to v1.37, async users started seeing Unclosed client session and Unclosed connector warnings at shutdown. The root cause is that the async client holds an aiohttp session that needs an async context manager to close cleanly. A maintainer showed the correct pattern: async with genai.Client(...).aio. The reporter later confirmed the warnings were gone in v1.52.0.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

Those warnings mean the async client's underlying aiohttp session was never closed, and they started appearing for async users after v1.37. Use the async client as a context manager, async with genai.Client(...).aio, so the session closes cleanly at the end of the block. The reporter confirmed the issue was gone in v1.52.0, so also make sure you are on a recent release. If you see this on old code, wrapping the client usage in the async context manager is the fix. Source: https://github.com/googleapis/python-genai/issues/1388

Source: https://github.com/googleapis/python-genai/issues/1388