fix: give the getUpdates client its own connection pool - #214
Open
mzored wants to merge 1 commit into
Open
Conversation
Long polling uses a separate HTTP client whose connection pool holds a single connection by default. When a long-running getUpdates request is torn down mid-flight, that connection can stay checked out and every later poll fails with "Pool timeout: All connections in the connection pool are occupied" — permanently, even after the network recovers. Set get_updates_connection_pool_size(8) so polling can recover on its own, and cover the wiring with a unit test. Fixes RichardAtCT#213
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Long polling in python-telegram-bot uses a separate HTTP client from the one configured in
initialize(), and its connection pool holds a single connection by default. If a long-runninggetUpdatesrequest is torn down mid-flight, that connection can stay checked out and every later poll fails immediately withPool timeout: All connections in the connection pool are occupied— permanently, even after the network recovers. The process stays alive and the retry loop keeps running, so the bot looks healthy while receiving nothing.This sets
get_updates_connection_pool_size(8)so the poller has headroom to recover on its own. Same class of problem as #166, which fixed pool corruption for the main client only.Related Issue
Fixes #213 — full analysis and reproduction there.
Type of Change
Changes
src/bot/core.py: setget_updates_connection_pool_size(8)on the application builder.tests/unit/test_bot/test_core_connection_pool.py: assert thegetUpdatesclient is not left on the default single-connection pool.Testing
531 passedReproduced deterministically by severing the connection to the upstream mid-
getUpdatesfor ~60s and then restoring it. Before: ~60Pool timeouterrors per minute after restore, zero successful requests,CLOSE_WAITsocket persisting. After: three consecutive cycles, polling recovers each time, noCLOSE_WAITaccumulation.The new test fails on
mainand passes with the fix.Checklist
make formathas been run (black, isort, flake8 clean)