Fix get_ip when no external network (#9700)

This commit is contained in:
ybyang authored and GitHub committed 2025-08-27 10:28:52 -07:00
1 parent db0831e019
commit fd18995cf3
1 file changed
+9
+9
View File
@@ -1964,6 +1964,15 @@ def get_ip() -> str:
except Exception:
pass
# try using hostname
hostname = socket.gethostname()
try:
ip_addr = socket.gethostbyname(hostname)
warnings.warn("using local ip address: {}".format(ip_addr))
return ip_addr
except Exception:
pass
warnings.warn(
"Failed to get the IP address, using 0.0.0.0 by default."
"The value can be set by the environment variable"