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

Using async dns resolver hardcode disabled #6836

Closed
1 task done
Rustik665 opened this issue Jul 21, 2022 · 3 comments
Closed
1 task done

Using async dns resolver hardcode disabled #6836

Rustik665 opened this issue Jul 21, 2022 · 3 comments
Labels

Comments

@Rustik665
Copy link

Rustik665 commented Jul 21, 2022

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.
image

To Reproduce

  1. pip install aiohttp aiodns
  2. run a python console
  3. import aiohttp
  4. 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

  • I agree to follow the aio-libs Code of Conduct
@Rustik665 Rustik665 added the bug label Jul 21, 2022
@Dreamsorcerer
Copy link
Member

Dreamsorcerer commented Jul 22, 2022

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 9fbb7d7
Which mentions this issue: #559

So, it looks like c-ares, used by aiodns, was causing issues. It appears this issue is related to the problem: c-ares/c-ares#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).

@bdraco
Copy link
Member

bdraco commented Mar 26, 2024

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

resp = await self._resolver.gethostbyname(host, family)

c-ares now has getaddrinfo so I've opened a PR to aiodns to add support for it aio-libs/aiodns#118 which should make AsyncResolver be able to behave similar to ThreadedResolver

@Dreamsorcerer
Copy link
Member

It's enabled again now.

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

No branches or pull requests

3 participants