Revert "fix(agent): release pool FDs on owning-thread client close (#61979)" (#62141)

This reverts commit cd7a8dfde0.
This commit is contained in:
Teknium 2026-07-10 19:12:32 -07:00 committed by GitHub
parent 5e849942c3
commit 5ba2d167ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 129 deletions

View file

@ -3992,18 +3992,17 @@ class AIAgent:
return create_openai_client(self, client_kwargs, reason=reason, shared=shared)
@staticmethod
def _force_close_tcp_sockets(client: Any, *, release_fds: bool = False) -> int:
def _force_close_tcp_sockets(client: Any) -> int:
"""Forwarder — see ``agent.agent_runtime_helpers.force_close_tcp_sockets``."""
from agent.agent_runtime_helpers import force_close_tcp_sockets
return force_close_tcp_sockets(client, release_fds=release_fds)
return force_close_tcp_sockets(client)
def _close_openai_client(self, client: Any, *, reason: str, shared: bool) -> None:
if client is None:
return
# Owning-thread dispose: shutdown + release FDs so already-shutdown
# sockets don't linger in kernel CLOSED state (#61979). Cross-thread
# abort uses _abort_request_openai_client (release_fds=False) instead.
force_closed = self._force_close_tcp_sockets(client, release_fds=True)
# Force-close TCP sockets first to prevent CLOSE-WAIT accumulation,
# then do the graceful SDK-level close.
force_closed = self._force_close_tcp_sockets(client)
try:
client.close()
logger.info(