[Dashboard] Update dashboard port checking so that we can instantly reuse the dashboard port (#11487)

Co-authored-by: Allen Yin <allenyin@anyscale.io>
This commit is contained in:
Allen
2020-10-20 19:19:50 -07:00
committed by GitHub
parent 6d11fb8bc6
commit 2fc3237045
+2 -2
View File
@@ -1019,10 +1019,11 @@ def start_dashboard(require_dashboard,
Returns:
ProcessInfo for the process that was started.
"""
port_test_socket = socket.socket()
port_test_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
if port == ray_constants.DEFAULT_DASHBOARD_PORT:
while True:
try:
port_test_socket = socket.socket()
port_test_socket.bind(("127.0.0.1", port))
port_test_socket.close()
break
@@ -1030,7 +1031,6 @@ def start_dashboard(require_dashboard,
port += 1
else:
try:
port_test_socket = socket.socket()
port_test_socket.bind(("127.0.0.1", port))
port_test_socket.close()
except socket.error: