Skip to content

Commit

Permalink
also drop idling connction on max_keepalive == idling_count
Browse files Browse the repository at this point in the history
  • Loading branch information
T-256 committed Jun 12, 2024
1 parent 07c0660 commit ffb789a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions httpcore/_async/connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ def _assign_requests_to_connections(self) -> List[AsyncConnectionInterface]:
self._connections.remove(connection)
closing_connections.append(connection)
elif connection.is_idle():
if idling_count > self._max_keepalive_connections:
# log: "closing idle connection"
self._connections.remove(connection)
closing_connections.append(connection)
else:
if idling_count < self._max_keepalive_connections:
idling_count += 1
continue
# log: "closing idle connection"
self._connections.remove(connection)
closing_connections.append(connection)

# Assign queued requests to connections.
for pool_request in list(self._requests):
Expand Down
10 changes: 5 additions & 5 deletions httpcore/_sync/connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ def _assign_requests_to_connections(self) -> List[ConnectionInterface]:
self._connections.remove(connection)
closing_connections.append(connection)
elif connection.is_idle():
if idling_count > self._max_keepalive_connections:
# log: "closing idle connection"
self._connections.remove(connection)
closing_connections.append(connection)
else:
if idling_count < self._max_keepalive_connections:
idling_count += 1
continue
# log: "closing idle connection"
self._connections.remove(connection)
closing_connections.append(connection)

# Assign queued requests to connections.
for pool_request in list(self._requests):
Expand Down

0 comments on commit ffb789a

Please sign in to comment.