Skip to content

Commit

Permalink
[PR #8522/5a9e5006 backport][3.10] Restore AsyncResolver to be the de…
Browse files Browse the repository at this point in the history
…fault resolver (#8523)

Co-authored-by: J. Nick Koston <nick@koston.org>
  • Loading branch information
patchback[bot] and bdraco committed Jul 21, 2024
1 parent 35b5508 commit 95897b1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGES/8522.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Restore :py:class:`~aiohttp.resolver.AsyncResolver` to be the default resolver. -- by :user:`bdraco`.

:py:class:`~aiohttp.resolver.AsyncResolver` was disabled by default because
of IPv6 compatibility issues. These issues have been resolved and
:py:class:`~aiohttp.resolver.AsyncResolver` is again now the default resolver.
6 changes: 3 additions & 3 deletions aiohttp/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

__all__ = ("ThreadedResolver", "AsyncResolver", "DefaultResolver")


try:
import aiodns

# aiodns_default = hasattr(aiodns.DNSResolver, 'getaddrinfo')
aiodns_default = hasattr(aiodns.DNSResolver, "getaddrinfo")
except ImportError: # pragma: no cover
aiodns = None # type: ignore[assignment]
aiodns_default = False


aiodns_default = False

_NUMERIC_SOCKET_FLAGS = socket.AI_NUMERICHOST | socket.AI_NUMERICSERV
_SUPPORTS_SCOPE_ID = sys.version_info >= (3, 9, 0)

Expand Down
12 changes: 7 additions & 5 deletions tests/test_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,11 @@ async def test_async_resolver_aiodns_not_present(loop, monkeypatch) -> None:
AsyncResolver(loop=loop)


def test_default_resolver() -> None:
# if getaddrinfo:
# assert DefaultResolver is AsyncResolver
# else:
# assert DefaultResolver is ThreadedResolver
@pytest.mark.skipif(not getaddrinfo, reason="aiodns >=3.2.0 required")
def test_aio_dns_is_default() -> None:
assert DefaultResolver is AsyncResolver


@pytest.mark.skipif(getaddrinfo, reason="aiodns <3.2.0 required")
def test_threaded_resolver_is_default() -> None:
assert DefaultResolver is ThreadedResolver

0 comments on commit 95897b1

Please sign in to comment.