-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix warnings usage related to RequestsWrapper, Openmetrics and Prometheus #5080
Conversation
4a2f206
to
967f6fa
Compare
Codecov Report
|
da009bf
to
e88f027
Compare
e88f027
to
f53af46
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot do something that would affect every check, nor can we remove the option. Both are breaking changes. Let's discuss this 🙂
A few thoughts:
My suggestion is just to drop the lock. We may lose some warnings (I don't think we can get more?) but that sounds very low risk. It would only happen when people put Oh and start by checking the conditional to not enter catch_warnings uselessly. |
@therve Thanks for the feedbacks.
My hypothesis is that, since the lock is surrounding the http calls, the lock is just waiting for the http calls to finish. Hence, making then in some way sequential.
You mean, dropping the lock, but keeping the Since
I'm not sure what you mean :) |
I mean by unpredictable it's related to warnings, no? What else could happen?
Move up the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, but a few issues in tests.
7ee8a64
to
9123fd2
Compare
4e07b9c
to
9bc997f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!
What does this PR do?
Remove
warning_lock
for RequestsWrapper. The warning lock is a bottleneck for requests calls made viaRequestsWrapper
.Replace
disable_warnings
withdisable_warnings_ctx
for Openmetrics and Prometheus mixinsdisable_warnings
effect was never restored/reverted.disable_warnings_ctx
instead ofwarnings.catch_warnings
.warnings.catch_warnings
is not thread-safe and might leave thewarnings
global variables in a unpredictable state.warnings.filters
leak issue by using a custom version called_simplefilter_py2
Each call to
disable_warnings(InsecureRequestWarning)
orwarnings.simplefilter('ignore', InsecureRequestWarning)
is adding an item towarnings.filters
for Python 2, which cause a memory leak.Python 3 does not have that issue, because it removes items before appending: https://github.com/python/cpython/blob/1f864016950079a618a916140f3abe6480a8e22d/Lib/warnings.py#L186
Python 2 does not: https://github.com/python/cpython/blob/e6499033032d5b647e43a3b49da0c1c64b151743/Lib/warnings.py#L112
Motivation
The warning lock is a bottleneck for requests calls made via
RequestsWrapper
. It makes some simple requests that should take~300ms
to20-40secs
.CAVEAT: once
disable_warnings(InsecureRequestWarning)
(akawarnings.simplefilter('ignore', InsecureRequestWarning)
) is called, it has a global effect for all checks.Additional Notes
First 2/3 of the chart: before the change

Last 1/3 of the chart: after the change