Using async dns resolver hardcode disabled
Describe the bug
In file aiohttp/resolver.py I found that selecting of async resolver has beed disabled(commented).
And that's the reason to use ThreadedResolver whether you have aiodns or not.
Here are the changes after which everything will work well.

To Reproduce
- pip install aiohttp aiodns
- run a python console
- import aiohttp
- print(aiohttp.DefaultResolver)
Expected behavior
aiohttp should use AsyncResolver, if we have aiodns installed
Logs/tracebacks
[rr.fayzullin@r02-fayzullinnx aiohttp]$ pip list |grep aio
aioari 0.10.2
aiodns 3.0.0
aiohttp 3.8.1
aiomysql 0.0.21
aiosignal 1.2.0
aioswagger11 0.9.1
[rr.fayzullin@r02-fayzullinnx aiohttp]$
PyDev console: starting.
Python 3.7.3 (default, Mar 11 2020, 12:41:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
import aiodns
import aiohttp
print(aiohttp.DefaultResolver)
<class 'aiohttp.resolver.ThreadedResolver'>
Python Version
$ python --version
Python 3.7.3
aiohttp Version
$ python -m pip show aiohttp
Name: aiohttp
Version: 3.8.1
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author:
Author-email:
License: Apache 2
Location: /home/local/REGION/rr.fayzullin/.local/lib/python3.7/site-packages
Requires: aiosignal, async-timeout, asynctest, attrs, charset-normalizer, frozenlist, multidict, typing-extensions, yarl
Required-by: aioswagger11
multidict Version
$ python -m pip show multidict
Name: multidict
Version: 4.7.6
Summary: multidict implementation
Home-page: https://github.com/aio-libs/multidict
Author: Andrew Svetlov
Author-email: [email protected]
License: Apache 2
Location: /home/local/REGION/rr.fayzullin/.local/lib/python3.7/site-packages
Requires:
Required-by: aiohttp, yarl
yarl Version
$ python -m pip show yarl
Name: yarl
Version: 1.6.0
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl/
Author: Andrew Svetlov
Author-email: [email protected]
License: Apache 2
Location: /home/local/REGION/rr.fayzullin/.local/lib/python3.7/site-packages
Requires: idna, multidict, typing-extensions
Required-by: aiohttp
OS
CentOS 7 3.10.0-1127.18.2.el7.x86_64
Related component
Client
Additional context
No response
Code of Conduct
- [x] I agree to follow the aio-libs Code of Conduct
Rather than a screenshot, it would be better if you found the code on Github and figured out why it was commented out.
In this case, the commit is https://github.com/aio-libs/aiohttp/commit/9fbb7d708375e0ba01d435c1e8cf41912381c0fc Which mentions this issue: https://github.com/aio-libs/aiohttp/issues/559
So, it looks like c-ares, used by aiodns, was causing issues. It appears this issue is related to the problem: https://github.com/c-ares/c-ares/issues/70
So, at a glance, it looks like the issue is probably fixed now and we can revert that commit. However, it would be great if someone can actually take a look through that issue and test out that the problem has indeed been fixed (plus create a PR to revert the change).
I just tried to switch Home Assistant to use the AsyncResolver to solve a problem with the executor being overloaded, and found that its always returning IPv6 because of https://github.com/aio-libs/aiohttp/blob/aa014a9c1084368a01a79f09bb238486e0aa164a/aiohttp/resolver.py#L91
c-ares now has getaddrinfo so I've opened a PR to aiodns to add support for it https://github.com/saghul/aiodns/pull/118 which should make AsyncResolver be able to behave similar to ThreadedResolver