From 12986f818362e8790fe4ec43b87e02591e78379d Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 10 May 2023 14:30:16 +0100 Subject: [PATCH] Fix erronous pool timeout case --- httpcore/_async/connection_pool.py | 3 ++- httpcore/_sync/connection_pool.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/httpcore/_async/connection_pool.py b/httpcore/_async/connection_pool.py index e6c4ef66..6ba8d46b 100644 --- a/httpcore/_async/connection_pool.py +++ b/httpcore/_async/connection_pool.py @@ -31,7 +31,8 @@ def unset_connection(self) -> None: async def wait_for_connection( self, timeout: Optional[float] = None ) -> AsyncConnectionInterface: - await self._connection_acquired.wait(timeout=timeout) + if self.connection is None: + await self._connection_acquired.wait(timeout=timeout) assert self.connection is not None return self.connection diff --git a/httpcore/_sync/connection_pool.py b/httpcore/_sync/connection_pool.py index 53536d05..b4cca11f 100644 --- a/httpcore/_sync/connection_pool.py +++ b/httpcore/_sync/connection_pool.py @@ -31,7 +31,8 @@ def unset_connection(self) -> None: def wait_for_connection( self, timeout: Optional[float] = None ) -> ConnectionInterface: - self._connection_acquired.wait(timeout=timeout) + if self.connection is None: + self._connection_acquired.wait(timeout=timeout) assert self.connection is not None return self.connection