suppress misleading DNSLookupError on cancelled connections

This should be removed after Twisted's ticket
https://twistedmatrix.com/trac/ticket/9696 is fixed (and we increase our
dependency to require a version with the fix).

refs #347
This commit is contained in:
Brian Warner 2019-08-11 21:23:18 -07:00
parent 49c36b0277
commit a489f5da2b

View File

@ -10,7 +10,7 @@ from twisted.internet.defer import DeferredList, CancelledError
from twisted.internet.endpoints import serverFromString
from twisted.internet.protocol import ClientFactory, ServerFactory
from twisted.internet.address import HostnameAddress, IPv4Address, IPv6Address
from twisted.internet.error import ConnectingCancelledError
from twisted.internet.error import ConnectingCancelledError, DNSLookupError
from twisted.python import log
from .. import ipaddrs # TODO: move into _dilation/
from .._interfaces import IDilationConnector, IDilationManager
@ -313,6 +313,10 @@ class Connector(object):
self._connect, ep, desc, is_relay)
d.addErrback(lambda f: f.trap(ConnectingCancelledError,
CancelledError))
# TODO: HostnameEndpoint.connect catches CancelledError and replaces
# it with DNSLookupError. Remove this workaround when
# https://twistedmatrix.com/trac/ticket/9696 is fixed.
d.addErrback(lambda f: f.trap(DNSLookupError))
d.addErrback(log.err)
self._pending_connectors.add(d)