From 2c94c12fc0623b9185a8d6187cc4d48d7750d9a3 Mon Sep 17 00:00:00 2001 From: Jonathan Keljo Date: Sun, 15 Mar 2020 12:29:46 -0700 Subject: [PATCH] Reset the tableholder after connection attempts so that it will retry the connection later if needed --- homeassistant/components/sisyphus/__init__.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/sisyphus/__init__.py b/homeassistant/components/sisyphus/__init__.py index 5ad59da5dee347..841fbb68178a50 100644 --- a/homeassistant/components/sisyphus/__init__.py +++ b/homeassistant/components/sisyphus/__init__.py @@ -99,18 +99,23 @@ def name(self): async def get_table(self): """Return the Table held by this holder, connecting to it if needed.""" + if self._table: + return self._table + if not self._table_task: self._table_task = self._hass.async_create_task(self._connect_table()) return await self._table_task async def _connect_table(self): - - self._table = await Table.connect(self._host, self._session) - if self._name is None: - self._name = self._table.name - _LOGGER.debug("Connected to %s at %s", self._name, self._host) - return self._table + try: + self._table = await Table.connect(self._host, self._session) + if self._name is None: + self._name = self._table.name + _LOGGER.debug("Connected to %s at %s", self._name, self._host) + return self._table + finally: + self._table_task = None async def close(self): """Close the table held by this holder, if any."""