From ad036fd5645a023b8888798c1506557f462e0a1b Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Wed, 16 Dec 2020 16:09:13 -0800 Subject: [PATCH] Fix continue for debugger (#12862) --- python/ray/tests/test_ray_debugger.py | 27 +++++++++++++++++++++++++++ python/ray/util/rpdb.py | 7 +++++++ 2 files changed, 34 insertions(+) diff --git a/python/ray/tests/test_ray_debugger.py b/python/ray/tests/test_ray_debugger.py index 8007f8a7a..adea19684 100644 --- a/python/ray/tests/test_ray_debugger.py +++ b/python/ray/tests/test_ray_debugger.py @@ -37,6 +37,33 @@ def test_ray_debugger_breakpoint(shutdown_only): ray.get(result) +@pytest.mark.skipif( + platform.system() == "Windows", reason="Failing on Windows.") +def test_ray_debugger_commands(shutdown_only): + ray.init(num_cpus=2) + + @ray.remote + def f(): + ray.util.pdb.set_trace() + + result1 = f.remote() + result2 = f.remote() + + # Make sure that calling "continue" in the debugger + # gives back control to the debugger loop: + p = pexpect.spawn("ray debug") + p.expect("Enter breakpoint index or press enter to refresh: ") + p.sendline("0") + p.expect("-> ray.util.pdb.set_trace()") + p.sendline("c") + p.expect("Enter breakpoint index or press enter to refresh: ") + p.sendline("0") + p.expect("-> ray.util.pdb.set_trace()") + p.sendline("c") + + ray.get([result1, result2]) + + @pytest.mark.skipif( platform.system() == "Windows", reason="Failing on Windows.") def test_ray_debugger_stepping(shutdown_only): diff --git a/python/ray/util/rpdb.py b/python/ray/util/rpdb.py index 33d430ea0..134e0b4ec 100644 --- a/python/ray/util/rpdb.py +++ b/python/ray/util/rpdb.py @@ -125,6 +125,13 @@ class RemotePdb(Pdb): do_q = do_exit = do_quit + def do_continue(self, arg): + self.__restore() + self.handle.connection.close() + return Pdb.do_continue(self, arg) + + do_c = do_continue + def set_trace(self, frame=None): if frame is None: frame = sys._getframe().f_back