[anonymous] catch exceptions in dnspython

This commit is contained in:
Yann Leboulanger 2005-11-20 10:51:22 +00:00
parent 929cb56ae2
commit 068e93194d
1 changed files with 10 additions and 7 deletions

View File

@ -1547,13 +1547,16 @@ class Connection:
query = '_xmpp-client._tcp.' + h.encode('utf-8')
try:
if HAS_DNSPYTHON:
answers = [x for x in dns.resolver.query(query, 'SRV')]
if answers:
for a in answers:
hosts.append({'host': str(a.target),
'port': int(a.port),
'prio': int(a.priority),
'weight': int(a.weight)})
try:
answers = [x for x in dns.resolver.query(query, 'SRV')]
if answers:
for a in answers:
hosts.append({'host': str(a.target),
'port': int(a.port),
'prio': int(a.priority),
'weight': int(a.weight)})
except:
pass
elif HAS_PYDNS:
# ensure we haven't cached an old configuration
DNS.ParseResolvConf()