diff --git a/httpcore/_async/connection_pool.py b/httpcore/_async/connection_pool.py index 089271344..a487990a8 100644 --- a/httpcore/_async/connection_pool.py +++ b/httpcore/_async/connection_pool.py @@ -237,6 +237,7 @@ async def handle_async_request( # behind catching 'BaseException' rather than 'Exception' here. logger.trace("remove from pool connection=%r", connection) await self._remove_from_pool(connection) + await connection.aclose() raise status_code, headers, stream, extensions = response diff --git a/httpcore/_sync/connection_pool.py b/httpcore/_sync/connection_pool.py index a60437b64..12b2d6565 100644 --- a/httpcore/_sync/connection_pool.py +++ b/httpcore/_sync/connection_pool.py @@ -237,6 +237,7 @@ def handle_request( # behind catching 'BaseException' rather than 'Exception' here. logger.trace("remove from pool connection=%r", connection) self._remove_from_pool(connection) + connection.close() raise status_code, headers, stream, extensions = response