Skip to content

Commit

Permalink
Hotfix for ray psutil on macOS (intel-analytics#2856)
Browse files Browse the repository at this point in the history
* Fix psutil test fail on macOS.
* Add exception handle for running without root.
  • Loading branch information
qiyuangong committed Sep 12, 2020
1 parent 5677cb8 commit 6f1e8a0
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions python/orca/src/bigdl/orca/ray/raycontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,22 @@ def kill_redundant_log_monitors(redis_address):
import subprocess
log_monitor_processes = []
for proc in psutil.process_iter(["name", "cmdline"]):
cmdline = subprocess.list2cmdline(proc.cmdline())
is_log_monitor = "log_monitor.py" in cmdline
is_same_redis = "--redis-address={}".format(redis_address)
if is_log_monitor and is_same_redis in cmdline:
log_monitor_processes.append(proc)
try:
# Avoid throw exception when listing lwsslauncher in macOS
if proc.name() is None or proc.name() == "lwsslauncher":
continue
cmdline = subprocess.list2cmdline(proc.cmdline())
is_log_monitor = "log_monitor.py" in cmdline
is_same_redis = "--redis-address={}".format(redis_address)
if is_log_monitor and is_same_redis in cmdline:
log_monitor_processes.append(proc)
except psutil.AccessDenied:
# psutil may encounter AccessDenied exceptions
# when it's trying to visit core services
if psutil.MACOS:
continue
else:
raise

if len(log_monitor_processes) > 1:
for proc in log_monitor_processes[1:]:
Expand Down

0 comments on commit 6f1e8a0

Please sign in to comment.