Let loop.create_connection do its getaddrinfo coroutine if there are no dns records left/available
This commit is contained in:
parent
68e35e631a
commit
3c06568ed5
1 changed files with 8 additions and 5 deletions
|
@ -297,18 +297,21 @@ class XMLStream(object):
|
||||||
else:
|
else:
|
||||||
if record:
|
if record:
|
||||||
host, address, port = record
|
host, address, port = record
|
||||||
|
self.address = (address, port)
|
||||||
self._service_name = host
|
self._service_name = host
|
||||||
else:
|
else:
|
||||||
self.event('connection_failed',
|
# No DNS records left, stop iterating
|
||||||
'No DNS record available for %s' % self.default_domain)
|
# and try (host, port) as a last resort
|
||||||
self.dns_answers = None
|
self.dns_answers = None
|
||||||
return
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
yield from loop.create_connection(lambda: self,
|
yield from loop.create_connection(lambda: self,
|
||||||
address,
|
self.address[0],
|
||||||
port,
|
self.address[1],
|
||||||
ssl=self.use_ssl)
|
ssl=self.use_ssl)
|
||||||
|
except Socket.gaierror as e:
|
||||||
|
self.event('connection_failed',
|
||||||
|
'No DNS record available for %s' % self.default_domain)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
log.debug('Connection failed: %s', e)
|
log.debug('Connection failed: %s', e)
|
||||||
self.event("connection_failed", e)
|
self.event("connection_failed", e)
|
||||||
|
|
Loading…
Reference in a new issue