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

Importing eventlet shouldn't read DNS configuration #462

Closed
nedbat opened this issue Jan 14, 2018 · 7 comments · Fixed by #737
Closed

Importing eventlet shouldn't read DNS configuration #462

nedbat opened this issue Jan 14, 2018 · 7 comments · Fixed by #737

Comments

@nedbat
Copy link

nedbat commented Jan 14, 2018

(Note: this stack trace is because I tried to use eventlet 0.22.0 on Python 2.6, which may be unsupported. This isn't about 2.6 support)

I have import eventlet in my code, and that one line resulted in reading host configurations on the off chance that I will eventually need to perform some DNS operations. It would be better if importing eventlet didn't try to do so much on import.

tests/test_concurrency.py:30: in <module>
    import eventlet
.tox/py26/lib/python2.6/site-packages/eventlet/__init__.py:10: in <module>
    from eventlet import convenience
.tox/py26/lib/python2.6/site-packages/eventlet/convenience.py:7: in <module>
    from eventlet.green import socket
.tox/py26/lib/python2.6/site-packages/eventlet/green/socket.py:21: in <module>
    from eventlet.support import greendns
.tox/py26/lib/python2.6/site-packages/eventlet/support/greendns.py:399: in <module>
    resolver = ResolverProxy(hosts_resolver=HostsResolver())
.tox/py26/lib/python2.6/site-packages/eventlet/support/greendns.py:181: in __init__
    self._load()
.tox/py26/lib/python2.6/site-packages/eventlet/support/greendns.py:207: in _load
    lines = self._readlines()
.tox/py26/lib/python2.6/site-packages/eventlet/support/greendns.py:197: in _readlines
    udata = fdata.decode(errors='ignore')
E   TypeError: decode() takes no keyword arguments
@nedbat
Copy link
Author

nedbat commented Jan 14, 2018

Actually, I can't find a statement about what Python versions are supported. Perhaps you mean to support 2.6, and this needs to be fixed?

@temoto
Copy link
Member

temoto commented Jan 14, 2018

Completely agree, Eventlet is doing too much on import. And it should be easy to make resolver defer reading configuration until first query.

If you don't use DNS resolver, this workaround helps: EVENTLET_NO_GREENDNS=yes python2.6 blabla.py

Green DNS resolution will not be supported for 2.6.

setup.py classifiers still say we support 2.6. But it's long been in the deprecation stage, for example, 2.6 tests are listed as "allowed to fail" on Travis CI.

@dtantsur
Copy link
Contributor

Still a problem with recent eventlet (presumably 0.32.0, don't know 100%). We see dns.resolver.NoResolverConfiguration on importing eventlet on a machine without DNS.

@musicinmybrain
Copy link

We see dns.resolver.NoResolverConfiguration on importing eventlet on a machine without DNS.

This showed up downstream in Fedora Linux when the python-eventlet package was updated to 0.32.0: https://bugzilla.redhat.com/show_bug.cgi?id=2017933. That aspect of this problem is, I think, a new regression.

@dtantsur
Copy link
Contributor

I've split away the DNS failure into #736 since this issue is a feature request.

@temoto
Copy link
Member

temoto commented Nov 16, 2021

Fixed by #737 thank you @dtantsur

@temoto temoto closed this as completed Nov 16, 2021
@Fat-Zer
Copy link

Fat-Zer commented Feb 21, 2022

Hi, on my system without a DNS resolver the test still fails with the following backtrace. If you may, could you skip the tests if there is no resolver configuration on a system?

test_clear (tests.greendns_test.TestProxyResolver) ... ERROR

======================================================================
ERROR: test_clear (tests.greendns_test.TestProxyResolver)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/tmp/portage/dev-python/eventlet-0.33.0/work/eventlet-0.33.0/tests/greendns_test.py", line 301, in test_clear
    resolver = rp._resolver
  File "/var/tmp/portage/dev-python/eventlet-0.33.0/work/eventlet-0.33.0/eventlet/support/greendns.py", line 334, in _resolver
    self.clear()
  File "/var/tmp/portage/dev-python/eventlet-0.33.0/work/eventlet-0.33.0/eventlet/support/greendns.py", line 342, in clear
    self._resolver = dns.resolver.Resolver(filename=self._filename)
  File "/usr/lib/python3.8/site-packages/dns/resolver.py", line 734, in __init__
    self.read_resolv_conf(filename)
  File "/usr/lib/python3.8/site-packages/dns/resolver.py", line 826, in read_resolv_conf
    raise NoResolverConfiguration
dns.resolver.NoResolverConfiguration: Resolver configuration could not be read or specified no nameservers.

----------------------------------------------------------------------

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

Successfully merging a pull request may close this issue.

5 participants