From 1baafc274304d1f6740c59a73c8fc11093d5477d Mon Sep 17 00:00:00 2001 From: florimondmanca Date: Sat, 12 Dec 2020 19:30:32 +0100 Subject: [PATCH] Ensure h2 connection gets closed --- httpcore/_async/http2.py | 1 + httpcore/_sync/http2.py | 1 + 2 files changed, 2 insertions(+) diff --git a/httpcore/_async/http2.py b/httpcore/_async/http2.py index 3c7404aa0..26ba6c56f 100644 --- a/httpcore/_async/http2.py +++ b/httpcore/_async/http2.py @@ -118,6 +118,7 @@ async def arequest( self.events[stream_id] = [] return await h2_stream.arequest(method, url, headers, stream, ext) except Exception: # noqa: PIE786 + self.h2_state.close_connection() await self.max_streams_semaphore.release() raise diff --git a/httpcore/_sync/http2.py b/httpcore/_sync/http2.py index fe2d55ebe..858e50ede 100644 --- a/httpcore/_sync/http2.py +++ b/httpcore/_sync/http2.py @@ -118,6 +118,7 @@ def request( self.events[stream_id] = [] return h2_stream.request(method, url, headers, stream, ext) except Exception: # noqa: PIE786 + self.h2_state.close_connection() self.max_streams_semaphore.release() raise