diff --git a/HISTORY.md b/HISTORY.md index c82ecb8ce8..013fb033fa 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,12 @@ Release History =============== +3.10.3 (2024-11-13) +------------------ + +**Fixed** +- Resolving lazy responses when emitted through a SOCKS, HTTP or HTTPS proxy. (#170) + 3.10.2 (2024-10-25) ------------------ diff --git a/src/niquests/__version__.py b/src/niquests/__version__.py index 7d87f81569..2c6fc79cba 100644 --- a/src/niquests/__version__.py +++ b/src/niquests/__version__.py @@ -9,9 +9,9 @@ __url__: str = "https://niquests.readthedocs.io" __version__: str -__version__ = "3.10.2" +__version__ = "3.10.3" -__build__: int = 0x031002 +__build__: int = 0x031003 __author__: str = "Kenneth Reitz" __author_email__: str = "me@kennethreitz.org" __license__: str = "Apache-2.0" diff --git a/src/niquests/adapters.py b/src/niquests/adapters.py index e69f71f71e..f2a7562bff 100644 --- a/src/niquests/adapters.py +++ b/src/niquests/adapters.py @@ -1212,6 +1212,11 @@ def gather(self, *responses: Response, max_fetch: int | None = None) -> None: if not self._promises: return + mgrs: list[PoolManager | ProxyManager] = [ + self.poolmanager, + *[pm for pm in self.proxy_manager.values()], + ] + # Either we did not have a list of promises to fulfill... if not responses: while True: @@ -1233,7 +1238,10 @@ def gather(self, *responses: Response, max_fetch: int | None = None) -> None: if low_resp is None: try: - low_resp = self.poolmanager.get_response() + for src in mgrs: + low_resp = src.get_response() + if low_resp is not None: + break except (ProtocolError, OSError) as err: raise ConnectionError(err) @@ -1308,11 +1316,14 @@ def gather(self, *responses: Response, max_fetch: int | None = None) -> None: continue try: - low_resp = self.poolmanager.get_response( - promise=response._promise - ) - except ValueError: - low_resp = None + for src in mgrs: + try: + low_resp = src.get_response(promise=response._promise) + except ValueError: + low_resp = None + + if low_resp is not None: + break except (ProtocolError, OSError) as err: raise ConnectionError(err) @@ -2306,6 +2317,11 @@ async def gather( if not self._promises: return + mgrs: list[AsyncPoolManager | AsyncProxyManager] = [ + self.poolmanager, + *[pm for pm in self.proxy_manager.values()], + ] + # Either we did not have a list of promises to fulfill... if not responses: while True: @@ -2327,7 +2343,10 @@ async def gather( if low_resp is None: try: - low_resp = await self.poolmanager.get_response() + for src in mgrs: + low_resp = await src.get_response() + if low_resp is not None: + break except (ProtocolError, OSError) as err: raise ConnectionError(err) @@ -2402,11 +2421,14 @@ async def gather( continue try: - low_resp = await self.poolmanager.get_response( - promise=response._promise - ) - except ValueError: - low_resp = None + for src in mgrs: + try: + low_resp = await src.get_response(promise=response._promise) + except ValueError: + low_resp = None + + if low_resp is not None: + break except (ProtocolError, OSError) as err: raise ConnectionError(err)