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

When resolving DNS hostname fails, errno is different depending on the resolver used #1459

Closed
spellr opened this issue Sep 11, 2019 · 3 comments · Fixed by #1596
Closed

When resolving DNS hostname fails, errno is different depending on the resolver used #1459

spellr opened this issue Sep 11, 2019 · 3 comments · Fixed by #1596
Labels
Level: help wanted Type: Enhancement

Comments

@spellr
Copy link

@spellr spellr commented Sep 11, 2019

  • gevent version: 1.4.0
  • Python version: cPython 2.7.15
  • Operating System: Ubuntu Linux 18.04 Linux 5.0.0-27-generic x86_64

Description:

When resolving host to address, and failed to find host, the errno returned is different when using thread-dns or dnspython, and when using ares.
thread-dns returns EAI_NONAME, which makes sense.
dnspython return None, which is a little weird.
ares returns EINTR, which is very weird.

What I've run:

resolve.py:

from gevent import monkey
monkey.patch_all()

import socket

try:
    print socket.gethostbyname('www.some-non-existing-domain.com')
except socket.gaierror as e:
    print e.errno
$ python resolve.py 
-2
$ GEVENT_RESOLVER=dnspython python resolve.py 
None
$ GEVENT_RESOLVER=ares python resolve.py 
4
@spellr
Copy link
Author

@spellr spellr commented Sep 11, 2019

As a side note, this behavior is very bad when using PyMySQL.
When using ares, this code is stuck in an infinite loop.

@chenyosef
Copy link

@chenyosef chenyosef commented Sep 11, 2019

👍

@jamadden
Copy link
Member

@jamadden jamadden commented Sep 13, 2019

Different resolvers are different? 🤷‍♂ I'd review PRs that added this fact to the documentation or which got them to behave more like each other in a tested way. There are existing tests for that in test__socket_dns.py, and some are skipped if we're not using the system DNS resolver, perhaps that's a starting point.

@jamadden jamadden added Type: Enhancement Level: help wanted labels Sep 13, 2019
jamadden added a commit that referenced this issue Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Level: help wanted Type: Enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants