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

AsyncResolver not default when aiodns is installed. #2228

Closed
elektito opened this issue Aug 26, 2017 · 6 comments
Closed

AsyncResolver not default when aiodns is installed. #2228

elektito opened this issue Aug 26, 2017 · 6 comments
Labels

Comments

@elektito
Copy link

Long story short

The docs say the AsyncResolver is the default resolver used when aiodns is installed but this is not really the case.

Here's what current stable docs say:

Changed in version 1.0: The resolver is aiohttp.AsyncResolver now if aiodns is installed.

Expected behaviour

AsyncResolver being the default resolver when aiodns is installed.

Actual behaviour

ThreadedResolver is used.

Steps to reproduce

  1. Install aiodns: pip install aiodns.
  2. Check if AsyncResolver is default:
    >>> aiohttp.resolver.DefaultResolver == aiohttp.resolver.AsyncResolver
    False
    >>> aiohttp.resolver.DefaultResolver == aiohttp.resolver.ThreadedResolver
    True

Your environment

I'm using aiohttp version 2.2.3 with Python 3.5.2 on Ubuntu 16.04.3.

More observations

In /aiohttp/resolver.py we can clearly see this line:

aiodns_default = False

And then later on:

DefaultResolver = AsyncResolver if aiodns_default else ThreadedResolver
@asvetlov
Copy link
Member

Doc should reflect current state.
See #559 for information about disabling async resolver by default.

@ilansh
Copy link

ilansh commented Jan 25, 2018

Is it possible to explicitly set async resolver globally, or does it need to be set for each client session?

@asvetlov
Copy link
Member

No global state :)
Usually you should not create too many sessions but do it in very little places in your program.

@ilansh
Copy link

ilansh commented Jan 28, 2018

thanks @asvetlov .
So when using a session, the way to do it is by passing it a connector with async resolver? i.e.
ClientSession(connector=aiohttp.TCPConnector(resolver=aiohttp.AsyncResolver()))

@asvetlov
Copy link
Member

Yes

@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants