From a8b5523e616a74ac0ca34ad68330fba0792210f3 Mon Sep 17 00:00:00 2001 From: Kadir Can Ozden <101993364+bysiber@users.noreply.github.com> Date: Fri, 20 Feb 2026 06:07:29 +0300 Subject: [PATCH] Move HTTP/2 stream events cleanup inside state lock in _response_closed --- httpcore/_async/http2.py | 2 +- httpcore/_sync/http2.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/httpcore/_async/http2.py b/httpcore/_async/http2.py index dbd0beeb..50738f2e 100644 --- a/httpcore/_async/http2.py +++ b/httpcore/_async/http2.py @@ -408,8 +408,8 @@ async def _receive_remote_settings_change( async def _response_closed(self, stream_id: int) -> None: await self._max_streams_semaphore.release() - del self._events[stream_id] async with self._state_lock: + del self._events[stream_id] if self._connection_terminated and not self._events: await self.aclose() diff --git a/httpcore/_sync/http2.py b/httpcore/_sync/http2.py index ddcc1890..6dcb10b0 100644 --- a/httpcore/_sync/http2.py +++ b/httpcore/_sync/http2.py @@ -408,8 +408,8 @@ def _receive_remote_settings_change( def _response_closed(self, stream_id: int) -> None: self._max_streams_semaphore.release() - del self._events[stream_id] with self._state_lock: + del self._events[stream_id] if self._connection_terminated and not self._events: self.close()