diff options
author | mathieui <mathieui@mathieui.net> | 2015-02-24 19:00:37 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2015-02-24 19:17:45 +0100 |
commit | 8ac0ecdf4063345249ca15f35817262f3b29cdef (patch) | |
tree | 6cb3c64811487f1d90b590314399f218518b1ff9 | |
parent | dbd8115557f7f1b88b82ed23c0fb312b4d15100f (diff) | |
download | slixmpp-8ac0ecdf4063345249ca15f35817262f3b29cdef.tar.gz slixmpp-8ac0ecdf4063345249ca15f35817262f3b29cdef.tar.bz2 slixmpp-8ac0ecdf4063345249ca15f35817262f3b29cdef.tar.xz slixmpp-8ac0ecdf4063345249ca15f35817262f3b29cdef.zip |
Fix dns resolution without aiodns
(use loop.getaddrinfo instead of the blocking version)
-rw-r--r-- | slixmpp/xmlstream/resolver.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/slixmpp/xmlstream/resolver.py b/slixmpp/xmlstream/resolver.py index f2c3f989..a9c260f0 100644 --- a/slixmpp/xmlstream/resolver.py +++ b/slixmpp/xmlstream/resolver.py @@ -177,9 +177,11 @@ def get_A(host, resolver=None, use_aiodns=True): # If not using aiodns, attempt lookup using the OS level # getaddrinfo() method. if resolver is None or not use_aiodns: + loop = asyncio.get_event_loop() try: - recs = socket.getaddrinfo(host, None, socket.AF_INET, - socket.SOCK_STREAM) + recs = yield from loop.getaddrinfo(host, None, + family=socket.AF_INET, + type=socket.SOCK_STREAM) return [rec[4][0] for rec in recs] except socket.gaierror: log.debug("DNS: Error retrieving A address info for %s." % host) @@ -222,9 +224,11 @@ def get_AAAA(host, resolver=None, use_aiodns=True): if not socket.has_ipv6: log.debug("DNS: Unable to query %s for AAAA records: IPv6 is not supported", host) return [] + loop = asyncio.get_event_loop() try: - recs = socket.getaddrinfo(host, None, socket.AF_INET6, - socket.SOCK_STREAM) + recs = yield from loop.getaddrinfo(host, None, + family=socket.AF_INET6, + type=socket.SOCK_STREAM) return [rec[4][0] for rec in recs] except (OSError, socket.gaierror): log.debug("DNS: Error retreiving AAAA address " + \ |