Skip to content

Commit b0622c3

Browse files
committed
Only use reuse connections in the pool if they're open
1 parent 1b920a5 commit b0622c3

File tree

1 file changed

+7
-5
lines changed
  • packages/smithy-http/src/smithy_http/aio

1 file changed

+7
-5
lines changed

packages/smithy-http/src/smithy_http/aio/crt.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,15 @@ async def _get_connection(
273273
) -> "crt_http.HttpClientConnection":
274274
# TODO: Use CRT connection pooling instead of this basic kind
275275
connection_key = (url.scheme, url.host, url.port)
276-
if connection_key in self._connections:
277-
return self._connections[connection_key]
278-
else:
279-
connection = await self._create_connection(url)
280-
self._connections[connection_key] = connection
276+
connection = self._connections.get(connection_key)
277+
278+
if connection and connection.is_open():
281279
return connection
282280

281+
connection = await self._create_connection(url)
282+
self._connections[connection_key] = connection
283+
return connection
284+
283285
def _build_new_connection(
284286
self, url: core_interfaces.URI
285287
) -> ConcurrentFuture["crt_http.HttpClientConnection"]:

0 commit comments

Comments
 (0)