Skip to content

Commit 6e6cb6b

Browse files
kfstormAlex Wu
authored and
Alex Wu
committed
[Core] Fix ray start failure to due to bug of redis address detection (#11735)
* Fix ray start failure to due redis address detection bug * Address comment
1 parent 8f3c315 commit 6e6cb6b

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

python/ray/_private/services.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,20 @@ def find_redis_address(address=None):
118118
# the first argument.
119119
# Explanation: https://unix.stackexchange.com/a/432681
120120
# More info: https://github.com/giampaolo/psutil/issues/1179
121-
for arglist in proc.cmdline():
122-
# Given we're merely seeking --redis-address, we just split
123-
# every argument on spaces for now.
124-
for arg in arglist.split(" "):
125-
# TODO(ekl): Find a robust solution for locating Redis.
126-
if arg.startswith("--redis-address="):
127-
proc_addr = arg.split("=")[1]
128-
if address is not None and address != proc_addr:
129-
continue
130-
redis_addresses.add(proc_addr)
121+
cmdline = proc.cmdline()
122+
# NOTE(kfstorm): To support Windows, we can't use
123+
# `os.path.basename(cmdline[0]) == "raylet"` here.
124+
if len(cmdline) > 0 and "raylet" in os.path.basename(cmdline[0]):
125+
for arglist in cmdline:
126+
# Given we're merely seeking --redis-address, we just split
127+
# every argument on spaces for now.
128+
for arg in arglist.split(" "):
129+
# TODO(ekl): Find a robust solution for locating Redis.
130+
if arg.startswith("--redis-address="):
131+
proc_addr = arg.split("=")[1]
132+
if address is not None and address != proc_addr:
133+
continue
134+
redis_addresses.add(proc_addr)
131135
except psutil.AccessDenied:
132136
pass
133137
except psutil.NoSuchProcess:

python/ray/tests/test_advanced_3.py

+7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import ray.test_utils
1919
from ray import resource_spec
2020
import setproctitle
21+
import subprocess
2122

2223
from ray.test_utils import (check_call_ray, RayTestTimeoutException,
2324
wait_for_condition, wait_for_num_actors)
@@ -522,6 +523,12 @@ def export_definitions_from_worker(remote_function, actor_class):
522523
ray.get(export_definitions_from_worker.remote(f, Actor))
523524

524525

526+
def test_ray_start_and_stop():
527+
for i in range(10):
528+
subprocess.check_call(["ray", "start", "--head"])
529+
subprocess.check_call(["ray", "stop"])
530+
531+
525532
def test_invalid_unicode_in_worker_log(shutdown_only):
526533
info = ray.init(num_cpus=1)
527534

0 commit comments

Comments
 (0)