Fix withings race condition for access token (#69107)

pull/69171/head
Nenad Bogojevic 2022-04-03 05:39:44 +02:00 committed by GitHub
parent d7375f1a9c
commit ccd5ada341
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -494,7 +494,7 @@ class ConfigEntryWithingsApi(AbstractWithingsApi):
"""Perform an async request."""
asyncio.run_coroutine_threadsafe(
self.session.async_ensure_token_valid(), self._hass.loop
)
).result()
access_token = self._config_entry.data["token"]["access_token"]
response = requests.request(
@ -648,7 +648,11 @@ class DataManager:
try:
return await func()
except Exception as exception1: # pylint: disable=broad-except
await asyncio.sleep(0.1)
_LOGGER.debug(
"Failed attempt %s of %s (%s)", attempt, attempts, exception1
)
# Make each backoff pause a little bit longer
await asyncio.sleep(0.5 * attempt)
exception = exception1
continue