mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00
The function get_node_ip_address while catch an exception and return … (#2722)
…'127.0.0.1', when we forbid the external network. Instead of we can get ip address from hostname. The function get_node_ip_address while catch an exception and return '127.0.0.1' when we forbid the external network. Instead of we can get ip address from hostname. https://github.com/ray-project/ray/issues/2721
This commit is contained in:
parent
b4cba9a49f
commit
90ae8f11df
1 changed files with 8 additions and 0 deletions
|
@ -246,6 +246,14 @@ def get_node_ip_address(address="8.8.8.8:53"):
|
|||
node_ip_address = s.getsockname()[0]
|
||||
except Exception as e:
|
||||
node_ip_address = "127.0.0.1"
|
||||
# [Errno 101] Network is unreachable
|
||||
if e.errno == 101:
|
||||
try:
|
||||
# try get node ip address from host name
|
||||
host_name = socket.getfqdn(socket.gethostname())
|
||||
node_ip_address = socket.gethostbyname(host_name)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return node_ip_address
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue