Initialize the host variable so it can be used anywhere inside the function. This closes
@@ -193,6 +193,8 @@ def wait_port(port, protocol_family='IPv4', **retry_kwargs):
if not isinstance(e, socket.error) or not e.errno == errno.ECONNREFUSED:
raise
+ host = None
+
def connect():
# macOS gives EINVAL for all connection attempts after a ECONNREFUSED
# man 3 connect: "If connect() fails, the state of the socket is unspecified. [...]"
@@ -205,7 +207,7 @@ def wait_port(port, protocol_family='IPv4', **retry_kwargs):
try:
retry_exception(connect, exception_test=check, **retry_kwargs)
except Exception as e:
- raise Exception("wait_port timeout on port %s: %s" % (port, e))
+ raise Exception("wait_port timeout on host %s port %s: %s" % (host, port, e))
def wait_ports(ports, **retry_kwargs):
"""Wait up to timeout for all ports (on host) to be connectable.
