From 0fc989c6c19622710f03174c49927d66e21600a3 Mon Sep 17 00:00:00 2001 From: Robert Nishihara Date: Mon, 2 Apr 2018 00:34:20 -0700 Subject: [PATCH] Don't use 127.0.0.1 for local ip address. (#1596) * Don't use 127.0.0.1 for ip address. * Update test --- python/ray/worker.py | 5 ++--- test/runtest.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/python/ray/worker.py b/python/ray/worker.py index e2fd1f6a6..33f650b4b 100644 --- a/python/ray/worker.py +++ b/python/ray/worker.py @@ -1365,9 +1365,8 @@ def _init(address_info=None, # In this case, we launch a scheduler, a new object store, and some # workers, and we connect to them. We do not launch any processes that # are already registered in address_info. - # Use the address 127.0.0.1 in local mode. - node_ip_address = ("127.0.0.1" if node_ip_address is None - else node_ip_address) + if node_ip_address is None: + node_ip_address = ray.services.get_node_ip_address() # Use 1 local scheduler if num_local_schedulers is not provided. If # existing local schedulers are provided, use that count as # num_local_schedulers. diff --git a/test/runtest.py b/test/runtest.py index 8689b3706..186c9c23d 100644 --- a/test/runtest.py +++ b/test/runtest.py @@ -2032,7 +2032,7 @@ class GlobalStateAPI(unittest.TestCase): worker_info = ray.global_state.workers() self.assertEqual(len(worker_info), num_workers) for worker_id, info in worker_info.items(): - self.assertEqual(info["node_ip_address"], "127.0.0.1") + self.assertIn("node_ip_address", info) self.assertIn("local_scheduler_socket", info) self.assertIn("plasma_manager_socket", info) self.assertIn("plasma_store_socket", info)