From 84f9505a8d23a21005ea72a040e955124dd3c240 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Wed, 24 Aug 2011 22:40:57 -0700 Subject: [PATCH] Fix handling of DNS exceptions. --- sleekxmpp/xmlstream/xmlstream.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py index 1914769..061c295 100644 --- a/sleekxmpp/xmlstream/xmlstream.py +++ b/sleekxmpp/xmlstream/xmlstream.py @@ -673,11 +673,13 @@ class XMLStream(object): answers = dns.resolver.query(domain, dns.rdatatype.A) except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer): log.warning("No A records for %s" % domain) + return [((domain, port), 0, 0)] except dns.exception.Timeout: log.warning("DNS resolution timed out " + \ "for A record of %s" % domain) - answers = [((answer.address, port), 0, 0) for answer in answers] - return answers + return [((domain, port), 0, 0)] + else: + return [((ans.address, port), 0, 0) for ans in answers] else: log.warning("dnspython is not installed -- " + \ "relying on OS A record resolution")