mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 21:23:10 +08:00
Split out the part of get_node_ip_address for which the docstring is correct (#12796)
This commit is contained in:
@@ -373,7 +373,7 @@ def address_to_ip(address):
|
||||
return ":".join([ip_address] + address_parts[1:])
|
||||
|
||||
|
||||
def get_node_ip_address(address="8.8.8.8:53"):
|
||||
def node_ip_address_from_perspective(address):
|
||||
"""IP address by which the local node can be reached *from* the `address`.
|
||||
|
||||
Args:
|
||||
@@ -383,9 +383,6 @@ def get_node_ip_address(address="8.8.8.8:53"):
|
||||
Returns:
|
||||
The IP address by which the local node can be reached from the address.
|
||||
"""
|
||||
if ray.worker._global_node is not None:
|
||||
return ray.worker._global_node.node_ip_address
|
||||
|
||||
ip_address, port = address.split(":")
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
try:
|
||||
@@ -409,6 +406,12 @@ def get_node_ip_address(address="8.8.8.8:53"):
|
||||
return node_ip_address
|
||||
|
||||
|
||||
def get_node_ip_address(address="8.8.8.8:53"):
|
||||
if ray.worker._global_node is not None:
|
||||
return ray.worker._global_node.node_ip_address
|
||||
return node_ip_address_from_perspective(address)
|
||||
|
||||
|
||||
def create_redis_client(redis_address, password=None):
|
||||
"""Create a Redis client.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user