Silence urllib3 HTTP connection debug spam when DB-API is down - #14
Draft
lefi7z wants to merge 2 commits into
Draft
Silence urllib3 HTTP connection debug spam when DB-API is down#14lefi7z wants to merge 2 commits into
lefi7z wants to merge 2 commits into
Conversation
Set urllib3’s default log level to WARNING so DEBUG root logging does not print a line on every TCP connect. Slow IoniConnect.connect() polling from 10ms to 250ms when the server is down. Co-authored-by: lefi7z <lefi7z@users.noreply.github.com>
Wait up to timeout_s with short (0.5, 3) GET /api/ping attempts and 250 ms spacing instead of polling is_connected with production (6.06, 27) timeouts. Co-authored-by: lefi7z <lefi7z@users.noreply.github.com>
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.
Problem
With root logging at DEBUG (e.g.
-vvvon the testing CLI), connecting to a DB-API that is not running floods the console with:That line comes from urllib3, not application code. It was triggered because
IoniConnect.connect()polledis_connected(HTTPGET /api/ping) in a tight loop with only 10 ms between attempts, using the same (6.06, 27) timeouts as production traffic.Changes
pytrms/__init__.py— Setlogging.getLogger("urllib3")toWARNINGby default. Opt-in HTTP wire logging remains available viaenable_extended_logging().pytrms/clients/db_api.py—connect()now loops untiltimeout_s(default 10 s) with inlinedGET /api/pingprobes using (0.5, 3) timeouts and 250 ms spacing between failures. Steady-state_fetch_object()calls still use (6.06, 27).tests/test_logging.py— Assert urllib3 stays at WARNING+ unless extended logging is enabled.tests/test_db_api_connect.py— Cover probe timeouts and successful connect after a transient failure.Note
If you need full urllib3/request traces for debugging HTTP, call
pytrms.enable_extended_logging(logging.DEBUG)as before.