From 8ac0ecdf4063345249ca15f35817262f3b29cdef Mon Sep 17 00:00:00 2001 From: mathieui Date: Tue, 24 Feb 2015 19:00:37 +0100 Subject: Fix dns resolution without aiodns (use loop.getaddrinfo instead of the blocking version) --- slixmpp/xmlstream/resolver.py | 12 ++++++++---- 1 file 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 " + \ -- cgit v1.2.3