fix blocking startup when NAS is busy (#60360)

This commit is contained in:
Michael 2021-11-27 09:25:27 +01:00 committed by GitHub
parent 729394547c
commit d63e2d1db0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -298,6 +298,7 @@ class SynoApi:
else: else:
self.config_url = f"http://{entry.data[CONF_HOST]}:{entry.data[CONF_PORT]}" self.config_url = f"http://{entry.data[CONF_HOST]}:{entry.data[CONF_PORT]}"
self.initialized = False
# DSM APIs # DSM APIs
self.dsm: SynologyDSM = None self.dsm: SynologyDSM = None
self.information: SynoDSMInformation = None self.information: SynoDSMInformation = None
@ -347,6 +348,7 @@ class SynoApi:
await self._hass.async_add_executor_job(self._fetch_device_configuration) await self._hass.async_add_executor_job(self._fetch_device_configuration)
await self.async_update() await self.async_update()
self.initialized = True
@callback @callback
def subscribe(self, api_key: str, unique_id: str) -> Callable[[], None]: def subscribe(self, api_key: str, unique_id: str) -> Callable[[], None]:
@ -506,6 +508,9 @@ class SynoApi:
self.dsm.update, self._with_information self.dsm.update, self._with_information
) )
except (SynologyDSMLoginFailedException, SynologyDSMRequestException) as err: except (SynologyDSMLoginFailedException, SynologyDSMRequestException) as err:
if not self.initialized:
raise err
_LOGGER.warning( _LOGGER.warning(
"Connection error during update, fallback by reloading the entry" "Connection error during update, fallback by reloading the entry"
) )