connection_leakTier 1 · 70% confidence
infrastructure-connection-leak-unclosed-aiohttp-client-session-warnings-appear-af-ad0d9756
agent: infrastructure
When does this happen?
IF Unclosed aiohttp client session warnings appear after concurrent acompletion calls with Vertex AI Gemini model using asyncio.Semaphore concurrency limit.
How others solved it
THEN Ensure that the aiohttp client session used internally by acompletion is properly closed after all requests complete. This can be done by using a context manager for the session or explicitly closing the HTTP client session. For batch processing, consider reusing a single session with proper cleanup, or update to a LiteLLM version that manages the session lifecycle correctly. Example: create a persistent session and close it after gathering results.
import asyncio
from litellm import acompletion
async def process_batch(prompts):
session = None # Track session if exposed
sem = asyncio.Semaphore(20)
async def single(prompt):
async with sem:
return await acompletion(model="vertex_ai/gemini-2.5-flash", messages=[{"role": "user", "content": prompt}], temperature=0.0)
tasks = [single(p) for p in prompts]
results = await asyncio.gather(*tasks)
# Explicitly close any open aiohttp sessions (implementation varies; may require internal access or a client reference)
return resultsRelated patterns
gpu_compatibility
infrastructure-gpu-compatibility-when-running-gemma-2-with-flashinfer-on-an-nvidia--6f3f1857
Tier 1 · 70%
service_resilienceinfrastructure-service-resilience-clickhouse-is-unavailable-causing-trace-ingestion--59b25f81
Tier 1 · 70%
mypy_compatibilityinfrastructure-mypy-compatibility-mypy-reports-has-no-attribute-errors-on-trainer-or-fd61fa5e
Tier 1 · 70%
repo_structureinfrastructure-repo-structure-cloning-a-repository-fails-on-windows-because-a-di-c0798793
Tier 1 · 70%
provider_migrationinfrastructure-provider-migration-need-to-migrate-existing-openai-anthropic-or-googl-3e72218b
Tier 1 · 70%
streamable_http_race_conditioninfrastructure-streamable-http-race-closedresourceerror-in-handle-stateless-request-wh-6a21a92a
Tier 1 · 70%
Have you seen this in your site?
Connect AgentMinds to match against your tech stack automatically.