From a825a83c9f4de758f0b916c2daeb2b03c76bdff9 Mon Sep 17 00:00:00 2001 From: Andrea Pirlo <3339436+zhanghanyun@users.noreply.github.com> Date: Mon, 10 Jun 2024 06:52:51 +0800 Subject: [PATCH] Fix the error in generating the idle connection list --- httpcore/_async/connection_pool.py | 8 +++++++- httpcore/_sync/connection_pool.py | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/httpcore/_async/connection_pool.py b/httpcore/_async/connection_pool.py index 214dfc4b..da43b8dc 100644 --- a/httpcore/_async/connection_pool.py +++ b/httpcore/_async/connection_pool.py @@ -251,7 +251,13 @@ def _assign_requests_to_connections(self) -> List[AsyncConnectionInterface]: closing_connections.append(connection) elif ( connection.is_idle() - and len([connection.is_idle() for connection in self._connections]) + and len( + [ + connection + for connection in self._connections + if connection.is_idle() + ] + ) > self._max_keepalive_connections ): # log: "closing idle connection" diff --git a/httpcore/_sync/connection_pool.py b/httpcore/_sync/connection_pool.py index 01bec59e..13087c01 100644 --- a/httpcore/_sync/connection_pool.py +++ b/httpcore/_sync/connection_pool.py @@ -251,7 +251,13 @@ def _assign_requests_to_connections(self) -> List[ConnectionInterface]: closing_connections.append(connection) elif ( connection.is_idle() - and len([connection.is_idle() for connection in self._connections]) + and len( + [ + connection + for connection in self._connections + if connection.is_idle() + ] + ) > self._max_keepalive_connections ): # log: "closing idle connection"