From 73be23570145fbabe01ea7c83262860c21c35f06 Mon Sep 17 00:00:00 2001 From: Richard Liaw Date: Mon, 19 Feb 2018 16:10:37 -0800 Subject: [PATCH] Quick Fix for Killing Ray Notebooks (#1563) --- python/ray/scripts/scripts.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/python/ray/scripts/scripts.py b/python/ray/scripts/scripts.py index bf95ebe11..221d04a0e 100644 --- a/python/ray/scripts/scripts.py +++ b/python/ray/scripts/scripts.py @@ -238,8 +238,14 @@ def stop(): "awk '{ print $2 }') 2> /dev/null"], shell=True) # Find the PID of the jupyter process and kill it. - subprocess.call(["kill $(ps aux | grep jupyter | grep -v grep | " - "awk '{ print $2 }') 2> /dev/null"], shell=True) + try: + from notebook.notebookapp import list_running_servers + pids = [str(server["pid"]) for server in list_running_servers() + if "/tmp/raylogs" in server["notebook_dir"]] + subprocess.call(["kill {} 2> /dev/null".format( + " ".join(pids))], shell=True) + except ImportError: + pass @click.command()