Skip to content

Commit

Permalink
Only close scheduler in SpecCluster if it exists
Browse files Browse the repository at this point in the history
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 "<stdin>", line 1, in <module>
  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.
  • Loading branch information
mrocklin committed Aug 15, 2022
1 parent 3647cfe commit 88a6f5e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion distributed/deploy/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 88a6f5e

Please sign in to comment.