Commit graph

4 commits

Author SHA1 Message Date
mateo-berri
2f240b2a12 Reapply "Merge remote-tracking branch 'origin/litellm_oss_staging_04_21_2026' into fix/bedrock-invoke-output-config-effort-4-6"
This reverts commit d10ef78ffa.
2026-04-22 20:48:39 -07:00
mateo-berri
d10ef78ffa Revert "Merge remote-tracking branch 'origin/litellm_oss_staging_04_21_2026' into fix/bedrock-invoke-output-config-effort-4-6"
This reverts commit 9eeb0bf3d2, reversing
changes made to 8e7a663ce5.
2026-04-22 20:43:40 -07:00
Ishaan Jaffer
e8461b5b97
style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
Cole McIntosh
4db25169d2
Fix: Properly close aiohttp client sessions to prevent resource leaks (#12251)
* Fix: Properly close aiohttp client sessions to prevent resource leaks (#12107)

- Add close() method to BaseLLMAIOHTTPHandler to properly close aiohttp ClientSession
- Create async_client_cleanup module with utility functions to close all cached async clients
- Register automatic cleanup at exit via atexit hook
- Export close_litellm_async_clients() function for manual cleanup
- Add comprehensive tests to verify resource cleanup

This fixes the "Unclosed client session" and "Unclosed connector" warnings when using acompletion with Gemini and other models that use aiohttp.

Fixes #12107

* Fix: Remove unused import to satisfy linter

* Fix: Extend cleanup to handle AsyncHTTPHandler instances used by Gemini

The original implementation only cleaned up BaseLLMAIOHTTPHandler instances,
but Gemini/Vertex AI providers use AsyncHTTPHandler objects which contain
httpx clients with aiohttp transports.

This commit extends the cleanup function to:
- Handle AsyncHTTPHandler instances by accessing their internal client
- Close both the aiohttp transport and httpx client
- Add generic fallback for any objects with aclose method

This properly fixes the resource leak warnings for all provider types.
2025-07-09 09:25:17 -07:00