From 1e7597b7dc03da7eead9b6abf84f822b5e74e8ba Mon Sep 17 00:00:00 2001 From: Kar Petrosyan <92274156+karpetrosyan@users.noreply.github.com> Date: Wed, 8 Nov 2023 17:59:52 +0400 Subject: [PATCH] Fix float("inf") timeouts (#846) * Fix float timeouts in synchronous event * Changelog --- CHANGELOG.md | 4 ++++ httpcore/_synchronization.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6346fb29..815d8a2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## Unreleased + +- Fix `float("inf")` timeouts in `Event.wait` function. (#846) + ## 1.0.1 (November 3rd, 2023) - Fix pool timeout to account for the total time spent retrying. (#823) diff --git a/httpcore/_synchronization.py b/httpcore/_synchronization.py index 2fbf961f..119d89fc 100644 --- a/httpcore/_synchronization.py +++ b/httpcore/_synchronization.py @@ -226,6 +226,8 @@ def set(self) -> None: self._event.set() def wait(self, timeout: Optional[float] = None) -> None: + if timeout == float("inf"): # pragma: no cover + timeout = None if not self._event.wait(timeout=timeout): raise PoolTimeout() # pragma: nocover