mirror of
https://github.com/wassname/ray.git
synced 2026-07-19 11:27:32 +08:00
Allow Ray processes to be started inside of gdb and tmux. (#3847)
This commit is contained in:
committed by
Robert Nishihara
parent
add8ae7063
commit
f067223c4a
@@ -0,0 +1,50 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
import ray
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ray_gdb_start():
|
||||
# Setup environment and start ray
|
||||
_environ = os.environ.copy()
|
||||
for process_name in ["RAYLET", "PLASMA_STORE"]:
|
||||
os.environ["RAY_{}_GDB".format(process_name)] = "1"
|
||||
os.environ["RAY_{}_TMUX".format(process_name)] = "1"
|
||||
|
||||
yield None
|
||||
|
||||
# Restore original environment and stop ray
|
||||
os.environ.clear()
|
||||
os.environ.update(_environ)
|
||||
ray.shutdown()
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.platform != "linux" and sys.platform != "linux2",
|
||||
reason="This test requires Linux.")
|
||||
def test_raylet_gdb(ray_gdb_start):
|
||||
# ray_gdb_start yields the expected process name
|
||||
ray.init(num_cpus=1)
|
||||
|
||||
@ray.remote
|
||||
def f():
|
||||
return 42
|
||||
|
||||
assert ray.get(f.remote()) == 42
|
||||
|
||||
# Check process name in `ps aux | grep gdb`
|
||||
for process_name in ["raylet/raylet", "plasma/plasma_store_server"]:
|
||||
pgrep_command = subprocess.Popen(
|
||||
["pgrep", "-f", "gdb.*{}".format(process_name)],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
assert pgrep_command.communicate()[0]
|
||||
subprocess.call(["pkill", "-f", "gdb.*{}".format(process_name)])
|
||||
Reference in New Issue
Block a user