fix(telegram): refresh general request pool after pool timeout - #53624
fix(telegram): refresh general request pool after pool timeout#53624izumi0uu wants to merge 1 commit into
Conversation
When PTB reports a pool timeout on the send path, the request was never sent, so retrying is safe. Resetting the general Bot API request pool before the next attempt avoids hammering a wedged httpx client. Constraint: issue NousResearch#53524 is validated on latest upstream/main with targeted Telegram unit tests, not a live 12h gateway repro. Rejected: drain the polling pool instead | the failure is on send/edit calls, not getUpdates. Confidence: high Scope-risk: narrow Directive: keep the pool reset limited to pool-timeout failures; do not apply it to all send errors. Tested: ./ .venv/bin/python -m pytest tests/gateway/test_telegram_thread_fallback.py -k "pool_timeout or refresh_general_pool" -q; ./ .venv/bin/python -m pytest tests/gateway/test_telegram_send_path_health.py tests/gateway/test_telegram_closewait_limits_31599.py -q Not-tested: long-running live Telegram gateway reproduction.
Duplicate of #53622 — both fix #53524 with the same mechanism (reset PTB's general Bot API request pool |
|
Closing as a duplicate of #53524's fix. Both your PR and #53622 by @yungchentang implemented the same general send-pool drain on pool timeout; #53622 was submitted first and included an asyncio.Lock to serialize concurrent drains, so it was the one salvaged in PR #54121 (#54121). Your shared _drain_bot_request_pool helper was a nice DRY shape — thanks for the contribution and the diagnosis. |
What does this PR do?
Fixes the Telegram gateway send-path failure behind #53524. When PTB reports a pool timeout on
send_message(), the request was never sent, so the adapter now resets the general Bot API request pool before retrying. That gives the next attempt a fresh httpx client instead of hammering the same exhausted pool.The old behavior was wrong because the send path treated pool timeout as retryable but left
_request[1]untouched, so retries could keep failing against a wedged general request pool.Related Issue
Fixes #53524
Type of Change
Changes Made
_request[0]only, and reset the general send/edit pool on send-side pool timeouts.How to Test
python -m pytest tests/gateway/test_telegram_thread_fallback.py -k "pool_timeout or refresh_general_pool" -qpython -m pytest tests/gateway/test_telegram_send_path_health.py tests/gateway/test_telegram_closewait_limits_31599.py -qChecklist
Code
fix(scope):,feat(scope):, etc.)Documentation & Housekeeping
Screenshots / Logs
Remaining Risks