Просмотр исходного кода

Stop retrying when Home Assistant is shutting down.

When a device is offline, and set to auto protocol version, there can be up to
11 retries before we give up, with each taking 5 seconds to time out.  This will delay shutdown by up to 1 minute, so stop retrying if HA is shutting down.

Issue #424
Jason Rumney 3 лет назад
Родитель
Сommit
d4664e35a7
1 измененных файлов с 6 добавлено и 5 удалено
  1. 6 5
      custom_components/tuya_local/device.py

+ 6 - 5
custom_components/tuya_local/device.py

@@ -410,11 +410,12 @@ class TuyaLocalDevice(object):
 
         for i in range(connections):
             try:
-                retval = await self._hass.async_add_executor_job(func)
-                if type(retval) is dict and "Error" in retval:
-                    raise AttributeError
-                self._api_protocol_working = True
-                return retval
+                if not self._hass.is_stopping:
+                    retval = await self._hass.async_add_executor_job(func)
+                    if type(retval) is dict and "Error" in retval:
+                        raise AttributeError
+                    self._api_protocol_working = True
+                    return retval
             except Exception as e:
                 _LOGGER.debug(
                     f"Retrying after exception {e} ({i}/{connections})",