From a2852f2329fbb462e3c6c08cac15e4e8ed13ff5d Mon Sep 17 00:00:00 2001 From: alanamarzoev Date: Mon, 31 Jul 2017 18:13:24 -0700 Subject: [PATCH] Allow multiple web UIs to be open at the same time. (#784) * Allow multiple web UIs to be open at the same time. * Changed formatting. --- python/ray/services.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/python/ray/services.py b/python/ray/services.py index 1b3cfd66e..31daf4754 100644 --- a/python/ray/services.py +++ b/python/ray/services.py @@ -472,6 +472,14 @@ def start_ui(redis_address, stdout_file=None, stderr_file=None, cleanup=True): new_notebook_directory = os.path.dirname(new_notebook_filepath) shutil.copy(notebook_filepath, new_notebook_filepath) port = 8888 + while True: + try: + port_test_socket = socket.socket() + port_test_socket.bind(("127.0.0.1", port)) + port_test_socket.close() + break + except OSError: + port += 1 new_env = os.environ.copy() new_env["REDIS_ADDRESS"] = redis_address command = ["jupyter", "notebook", "--no-browser",