Catch all exceptions when calling socket.getaddrinfo (#1355)

it serves two purposes:
1. We don't want accidentally break the thread
2. During the shutdown socket.gaierror become unresolvable and nasty exceptions are raised

Close: https://github.com/zalando/patroni/issues/1353
This commit is contained in:
Alexander Kukushkin
2020-01-15 12:38:34 +01:00
committed by GitHub
parent 9e8ae95bce
commit 102a12ea5a
+2 -2
View File
@@ -73,8 +73,8 @@ class DnsCachingResolver(Thread):
def _do_resolve(host, port):
try:
return socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM, socket.IPPROTO_TCP)
except socket.gaierror:
logger.warning('failed to resolve host %s', host)
except Exception as e:
logger.warning('failed to resolve host %s: %s', host, e)
return []