fix(aiohttp): only set enable_cleanup_closed when required - #21897
Merged
2 commits merged intoFeb 24, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Author
Contributor
Greptile SummaryThis PR conditionally applies
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| litellm/llms/custom_httpx/http_handler.py | Conditionally sets enable_cleanup_closed on TCPConnector only when AIOHTTP_NEEDS_CLEANUP_CLOSED is True. Clean, minimal change that correctly reuses the existing constant. |
| litellm/proxy/proxy_server.py | Same conditional enable_cleanup_closed fix applied to the proxy's shared aiohttp session initialization. Correctly imports and uses AIOHTTP_NEEDS_CLEANUP_CLOSED from constants. |
| tests/test_litellm/llms/custom_httpx/test_aiohttp_cleanup_closed.py | New test file with two tests verifying enable_cleanup_closed is set when needed and omitted when not needed for AsyncHTTPHandler._create_aiohttp_transport. Uses mocks correctly. |
| tests/test_litellm/proxy/test_aiohttp_cleanup_closed.py | New test file with two tests verifying the proxy's _initialize_shared_aiohttp_session conditionally passes enable_cleanup_closed. Mock patching is correct because the proxy function uses a local import. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Create aiohttp TCPConnector] --> B{AIOHTTP_NEEDS_CLEANUP_CLOSED?}
B -->|True: Python < 3.12.7 or 3.13.0| C[Set enable_cleanup_closed=True]
B -->|False: Python >= 3.12.7 and != 3.13.0| D[Omit enable_cleanup_closed]
C --> E[Create TCPConnector with kwargs]
D --> E
E --> F[Create ClientSession]
Last reviewed commit: 571d7c6
ghost
merged commit Feb 24, 2026
d0bcafa
into
BerriAI:litellm_oss_staging_02_23_2026
31 checks passed
Sameerlite
pushed a commit
that referenced
this pull request
Mar 3, 2026
* fix(aiohttp): only set enable_cleanup_closed when required * add tests
fzowl
pushed a commit
to fzowl/litellm
that referenced
this pull request
Jun 24, 2026
…1897) * fix(aiohttp): only set enable_cleanup_closed when required * add tests
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On modern Python versions (e.g. 3.13.7), aiohttp emits a warning when
enable_cleanup_closedis still provided.This change removes that warning while preserving behavior on Python versions that still require the workaround.
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewCI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Type
🐛 Bug Fix
Changes
enable_cleanup_closed=Truetoaiohttp.TCPConnectoron Python versions where this workaround is no longer needed.AIOHTTP_NEEDS_CLEANUP_CLOSED) to conditionally add the connector kwarg.