Enable sisyphus to recover from bad DNS without restart (#32846)
parent
e86fb3fc5c
commit
ef5f4b2aca
|
@ -99,18 +99,23 @@ class TableHolder:
|
|||
|
||||
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."""
|
||||
|
|
Loading…
Reference in New Issue