From 7ea8ecf8883cf17879c20e4fc9bc84f00383f345 Mon Sep 17 00:00:00 2001 From: disqualifier Date: Sun, 28 Jun 2026 15:49:30 -0400 Subject: [PATCH] fix: don't truncate sub-second timeout to 0 in noble backend (v0.1.1) int(timeout) truncated a fractional timeout (e.g. 0.5s) to 0, which noble treats as no/instant timeout. round up with math.ceil and floor at 1 so a sub-second timeout stays a real (>=1s) timeout. verified: 0.5/0.1/0.001 -> 1 (was 0); whole seconds unchanged. Signed-off-by: disqualifier --- pyproject.toml | 2 +- src/aioweb_tls/backends.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5406339..8f392b2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "aioweb_tls" -version = "0.1.0" +version = "0.1.1" description = "TLS-fingerprinting backends for aioweb — curl_cffi / noble_tls ExtendedSession subclasses, config-free, installable." requires-python = ">=3.10" dependencies = [ diff --git a/src/aioweb_tls/backends.py b/src/aioweb_tls/backends.py index 33181fd..f87a834 100644 --- a/src/aioweb_tls/backends.py +++ b/src/aioweb_tls/backends.py @@ -12,6 +12,7 @@ this module never fails because an extra is missing. """ import logging +import math from aioweb import Response @@ -169,7 +170,9 @@ class Noble: timeout = _coerce_timeout(kwargs.pop("timeout", None)) if timeout is not None: - kwargs["timeout_seconds"] = int(timeout) + # noble takes whole seconds; round UP so a sub-second timeout (e.g. 0.5) + # doesn't truncate to 0 (which would mean no/instant timeout) + kwargs["timeout_seconds"] = max(1, math.ceil(timeout)) proxy = kwargs.pop("proxy", None) if proxy: