From: Tom Christie Date: Thu, 25 Apr 2019 16:16:37 +0000 (+0100) Subject: Drop connections from pool on connection exceptions X-Git-Tag: 0.3.0~66^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ddf1cec65a0dc6c18d7a163ff2fc73b2eb134cce;p=thirdparty%2Fhttpx.git Drop connections from pool on connection exceptions --- diff --git a/httpcore/connection_pool.py b/httpcore/connection_pool.py index 4ba83ec3..6eaef9be 100644 --- a/httpcore/connection_pool.py +++ b/httpcore/connection_pool.py @@ -110,7 +110,12 @@ class ConnectionPool(Client): timeout: typing.Optional[TimeoutConfig] = None, ) -> Response: connection = await self.acquire_connection(request.url.origin, timeout=timeout) - response = await connection.send(request, ssl=ssl, timeout=timeout) + try: + response = await connection.send(request, ssl=ssl, timeout=timeout) + except BaseException as exc: + self.active_connections.remove(connection) + self.max_connections.release() + raise exc return response async def acquire_connection(