Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions distributed/cli/dask_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

@click.command(context_settings=dict(ignore_unknown_options=True))
@click.option("--host", type=str, default="", help="URI, IP or hostname of this server")
@click.option("--port", type=int, default=None, help="Serving port")
@click.option("--port", type=str, default=None, help="Serving port")
@click.option(
"--interface",
type=str,
Expand Down Expand Up @@ -130,6 +130,8 @@
def main(
host,
port,
protocol,
interface,
bokeh_port,
show,
dashboard,
Expand Down Expand Up @@ -162,8 +164,29 @@ def main(
)
dashboard = bokeh

if interface and "," in interface:
interface = interface.split(",")

if protocol and "," in protocol:
protocol = protocol.split(",")

if port:
if "," in port:
port = [int(p) for p in port.split(",")]
else:
port = int(port)

if port is None and (not host or not re.search(r":\d", host)):
port = 8786
if isinstance(protocol, list):
port = [8786] + [0] * (len(protocol) - 1)
else:
port = 8786

if isinstance(protocol, list) or isinstance(port, list):
if (not isinstance(protocol, list) or not isinstance(port, list)) or len(
port
) != len(protocol):
raise ValueError("--protocol and --port must both be lists of equal length")

sec = {
k: v
Expand Down Expand Up @@ -202,6 +225,8 @@ async def run():
security=sec,
host=host,
port=port,
protocol=protocol,
interface=interface,
dashboard=dashboard,
dashboard_address=dashboard_address,
http_prefix=dashboard_prefix,
Expand Down
16 changes: 16 additions & 0 deletions distributed/cli/tests/test_dask_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,22 @@ def test_dashboard_non_standard_ports(loop):
requests.get(f"http://localhost:{port2}/status/")


def test_multiple_protocols(loop):
port1 = open_port()
port2 = open_port()
with popen(
[
"dask-scheduler",
"--protocol=tcp,ws",
f"--port={port1},{port2}",
]
) as _:
with Client(f"tcp://127.0.0.1:{port1}", loop=loop):
pass
with Client(f"ws://127.0.0.1:{port2}", loop=loop):
pass


@pytest.mark.skipif(not LINUX, reason="Need 127.0.0.2 to mean localhost")
def test_dashboard_allowlist(loop):
pytest.importorskip("bokeh")
Expand Down