Add check to scheduler creation in SpecCluster
@@ -252,6 +252,7 @@ class SpecCluster(Cluster):
self.scheduler_spec = copy.copy(scheduler)
self.worker_spec = copy.copy(workers) or {}
self.new_spec = copy.copy(worker)
+ self.scheduler = None
self.workers = {}
self._i = 0
self.security = security or Security()
@@ -290,6 +291,7 @@ class SpecCluster(Cluster):
raise ValueError("Cluster is closed")
self._lock = asyncio.Lock()
+ self.status = Status.starting
if self.scheduler_spec is None:
try:
@@ -300,12 +302,12 @@ class SpecCluster(Cluster):
options = {"dashboard": True}
self.scheduler_spec = {"cls": Scheduler, "options": options}
+ # Check if scheduler has already been created by a subclass
+ if self.scheduler is None:
cls = self.scheduler_spec["cls"]
if isinstance(cls, str):
cls = import_term(cls)
self.scheduler = cls(**self.scheduler_spec.get("options", {}))
-
- self.status = Status.starting
self.scheduler = await self.scheduler
self.scheduler_comm = rpc(
getattr(self.scheduler, "external_address", None) or self.scheduler.address,
