Enable sisyphus to recover from bad DNS without restart (#32846)

This commit is contained in:
Jonathan Keljo 2020-04-02 07:33:54 -07:00 committed by GitHub
parent 5a55d50879
commit f8f05c4d0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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."""