From 88a6f5eb680da2df013f3a34bbbb6cff17974c17 Mon Sep 17 00:00:00 2001 From: Matthew Rocklin Date: Mon, 15 Aug 2022 12:23:12 -0500 Subject: [PATCH] Only close scheduler in SpecCluster if it exists In failure cases the scheduler may not have been created but close is still called, providing a traceback like the following: ```python-traceback Traceback (most recent call last): File "", line 1, in File "/home/mrocklin/workspace/distributed/distributed/deploy/spec.py", line 275, in __init__ self.sync(self._start) File "/home/mrocklin/workspace/distributed/distributed/utils.py", line 338, in sync return sync( File "/home/mrocklin/workspace/distributed/distributed/utils.py", line 405, in sync raise exc.with_traceback(tb) File "/home/mrocklin/workspace/distributed/distributed/utils.py", line 378, in f result = yield future File "/home/mrocklin/mambaforge/lib/python3.9/site-packages/tornado/gen.py", line 762, in run value = future.result() File "/home/mrocklin/workspace/distributed/distributed/deploy/spec.py", line 318, in _start await self._close() File "/home/mrocklin/workspace/distributed/distributed/deploy/spec.py", line 434, in _close await self.scheduler.close() AttributeError: 'NoneType' object has no attribute 'close' ``` This wasn't really an issue (things were already broken) but makes tracking down the real issue more of a pain. --- distributed/deploy/spec.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/distributed/deploy/spec.py b/distributed/deploy/spec.py index 57602b704e3..39558f1c7e6 100644 --- a/distributed/deploy/spec.py +++ b/distributed/deploy/spec.py @@ -431,7 +431,8 @@ async def _close(self): else: logger.warning("Cluster closed without starting up") - await self.scheduler.close() + if self.scheduler: + await self.scheduler.close() for w in self._created: assert w.status in { Status.closing,