瀏覽代碼

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 年之前
父節點
當前提交
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):
         for i in range(connections):
             try:
             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:
             except Exception as e:
                 _LOGGER.debug(
                 _LOGGER.debug(
                     f"Retrying after exception {e} ({i}/{connections})",
                     f"Retrying after exception {e} ({i}/{connections})",