python-zk/kazoo — pull request #124 by rgs1 (2013-09-19 02:23:15+00:00)
Title: Expand hosts (dns lookup) before calling create_connect

If we defer the getaddrinfo calls to socket.create_connection
then we don't actually know (nor log) to which exact IP we
are trying to connect (which is a bummer for cases in which Zk
is available via RR records).

By looking up the hosts early we can know which one we are connecting
to on every try.

Also - while we are at it - lets simplify _connect_loop so it's
a bit easier to follow along (otherwise it's unclear what is
controlled by retry() and what's is iterated by _connect_loop,
_connect_attempt and _connect, respectively).