From 5b04a024a5ed6badcc3ba5d5a6f5afcb642aa474 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Sun, 5 Jul 2026 22:02:37 +0530 Subject: [PATCH] docs(telegram): clarify fallback-branch limits wiring vs siblings Follow-up on the #58790 fallback-limits fix: tighten the now-stale _with_limits docstring and note on the fallback branch why it injects limits at the transport level (not via _with_limits) so a future editor does not re-route it through the client-level helper httpx would discard. --- plugins/platforms/telegram/adapter.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/platforms/telegram/adapter.py b/plugins/platforms/telegram/adapter.py index b23bdcf8d33..3fa37f94aed 100644 --- a/plugins/platforms/telegram/adapter.py +++ b/plugins/platforms/telegram/adapter.py @@ -3025,8 +3025,11 @@ class TelegramAdapter(BasePlatformAdapter): def _with_limits(httpx_kwargs: Optional[dict] = None) -> dict: """Merge tuned keepalive limits into httpx client kwargs. - A caller-supplied ``limits`` (none today) is left untouched; - otherwise the CLOSE_WAIT-safe limits are injected. + Used by the proxy and direct-DNS branches, where httpx honours + the client-level ``limits`` kwarg. A caller-supplied ``limits`` + is left untouched; otherwise the CLOSE_WAIT-safe limits are + injected. The fallback-IP branch does NOT use this helper — see + the ``_transport_kwargs`` note below for why. """ kwargs = dict(httpx_kwargs or {}) if _pool_limits is not None and "limits" not in kwargs: @@ -3055,9 +3058,12 @@ class TelegramAdapter(BasePlatformAdapter): # Keep request/update pools separate to reduce contention during # polling reconnect + bot API bootstrap/delete_webhook calls. # httpx ignores the client-level `limits` kwarg when a custom - # `transport` is supplied (#58790). Pass the tuned limits + # `transport` is supplied (#58790). Unlike the proxy/direct + # branches (which inject limits at the client level via + # `_with_limits`), this branch MUST pass the tuned limits # directly into TelegramFallbackTransport so its inner - # AsyncHTTPTransport instances honour keepalive_expiry. + # AsyncHTTPTransport instances honour keepalive_expiry — do not + # route this through `_with_limits`, httpx would discard it. _transport_kwargs: dict = {} if _pool_limits is not None: _transport_kwargs["limits"] = _pool_limits