Repository navigation
fix: resolve allowed hostnames with the real getaddrinfo - #552
Merged
Merged
Conversation
Since DNS blocking landed in #482, resolve_hostnames called the patched socket.getaddrinfo. With the README's conftest recipe (disable_socket() in pytest_runtest_setup, which runs before the plugin's hook) and a hostname in --allow-hosts, every test errored in setup with SocketBlockedError, and the resolution cache never filled. Call the saved _true_getaddrinfo instead, and point the test fixture that fakes DNS at it. Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Contributor
Merging this PR will improve performance by 50.37%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_bench_host_from_address |
24.6 µs | 16.3 µs | +50.37% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing resolve-true-getaddrinfo (5fd5d52) with main (d8db169)
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.
Since #482 added DNS blocking,
resolve_hostnamescalled the patchedsocket.getaddrinfo. With the README's conftest recipe (disable_socket()inpytest_runtest_setup) plus a hostname in--allow-hosts, every test errored in setup withSocketBlockedError, and the resolution cache never filled.Call the saved
_true_getaddrinfoinstead. The test fixture that fakes DNS now patches that name, and a new test covers the conftest recipe with--allow-hosts=localhost.