Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn only once when discarding connection when pool is full #3167

Open
EpicWink opened this issue Oct 24, 2023 · 2 comments
Open

Warn only once when discarding connection when pool is full #3167

EpicWink opened this issue Oct 24, 2023 · 2 comments

Comments

@EpicWink
Copy link

Context

When using libraries which use urllib3 in multiple threads, an end-user often sees the warning log:

urllib3.connectionpool: Connection pool is full, discarding connection: cloud.example.com. Connection pool size: 42

The warning only really needs to be displayed once (per pool), and future logs could probably be debug-level. Reducing the verbosity of logging will make it more informative and less likely to be ignored.

Alternatives

It's possible to go through each SDK's method of increasing the connection pool size to the thread count (if that configuration is exposed) to remove the warning, but this isn't the real issue here.

Duplicate

Related: #3074

Contribution

I would be happy to submit a PR

@ericdrosas87
Copy link

I just wanted to toss my hat into the ring and say that this is for sure something my team would utilize. Honestly, I'd prefer the option to disable the warning entirely.

I've tried to disable the warning with:

import warnings
with warnings.catch_warnings(action="ignore"):

...but urllib3 is still throwing the warning.

@ericdrosas87
Copy link

ericdrosas87 commented Apr 1, 2024

Coincidentally, I just found a way to ignore the warnings, I have to put this before:

import logging
for name in logging.Logger.manager.loggerDict.keys():
            if 'urllib3' in name:
                logging.getLogger(name).setLevel(logging.CRITICAL)

And then reset it after:

for name in logging.Logger.manager.loggerDict.keys():
            if 'urllib3' in name:
                logging.getLogger(name).setLevel(logging.WARNING)

Obviously, this is not ideal and is a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants