mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-06 17:11:14 +00:00
4db25169d2
* 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.
In total litellm runs 1000+ tests
[02/20/2025] Update:
To make it easier to contribute and map what behavior is tested,
we've started mapping the litellm directory in tests/litellm
This folder can only run mock tests.