|
195 | 195 | "stealing": WorkStealing,
|
196 | 196 | }
|
197 | 197 |
|
| 198 | +DEFAULT_SCHEDULER_PORT = 8786 |
| 199 | + |
198 | 200 |
|
199 | 201 | class ClientState:
|
200 | 202 | """A simple object holding information about a client."""
|
@@ -3574,7 +3576,6 @@ class Scheduler(SchedulerState, ServerNode):
|
3574 | 3576 | Time we expect certain functions to take, e.g. ``{'sum': 0.25}``
|
3575 | 3577 | """
|
3576 | 3578 |
|
3577 |
| - default_port = 8786 |
3578 | 3579 | _instances: ClassVar[weakref.WeakSet[Scheduler]] = weakref.WeakSet()
|
3579 | 3580 |
|
3580 | 3581 | worker_ttl: float | None
|
@@ -3686,8 +3687,18 @@ def __init__(
|
3686 | 3687 | interface=interface,
|
3687 | 3688 | protocol=protocol,
|
3688 | 3689 | security=security,
|
3689 |
| - default_port=self.default_port, |
| 3690 | + default_port=DEFAULT_SCHEDULER_PORT, |
3690 | 3691 | )
|
| 3692 | + if port is None: |
| 3693 | + self._fallback_start_addresses = addresses_from_user_args( |
| 3694 | + host=host, |
| 3695 | + port=0, |
| 3696 | + interface=interface, |
| 3697 | + protocol=protocol, |
| 3698 | + security=security, |
| 3699 | + ) |
| 3700 | + else: |
| 3701 | + self._fallback_start_addresses = [] |
3691 | 3702 |
|
3692 | 3703 | http_server_modules = dask.config.get("distributed.scheduler.http.routes")
|
3693 | 3704 | show_dashboard = dashboard or (dashboard is None and dashboard_address)
|
@@ -4094,11 +4105,14 @@ async def start_unsafe(self) -> Self:
|
4094 | 4105 |
|
4095 | 4106 | self._clear_task_state()
|
4096 | 4107 |
|
4097 |
| - for addr in self._start_address: |
| 4108 | + for addr, fallback_addr in itertools.zip_longest( |
| 4109 | + self._start_address, self._fallback_start_addresses |
| 4110 | + ): |
4098 | 4111 | await self.listen(
|
4099 | 4112 | addr,
|
4100 | 4113 | allow_offload=False,
|
4101 | 4114 | handshake_overrides={"pickle-protocol": 4, "compression": None},
|
| 4115 | + fallback_port_or_addr=fallback_addr, |
4102 | 4116 | **self.security.get_listen_args("scheduler"),
|
4103 | 4117 | )
|
4104 | 4118 | self.ip = get_address_host(self.listen_address)
|
|
0 commit comments