mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Fix withings race condition for access token (#69107)
This commit is contained in:
parent
d7375f1a9c
commit
ccd5ada341
@ -494,7 +494,7 @@ class ConfigEntryWithingsApi(AbstractWithingsApi):
|
|||||||
"""Perform an async request."""
|
"""Perform an async request."""
|
||||||
asyncio.run_coroutine_threadsafe(
|
asyncio.run_coroutine_threadsafe(
|
||||||
self.session.async_ensure_token_valid(), self._hass.loop
|
self.session.async_ensure_token_valid(), self._hass.loop
|
||||||
)
|
).result()
|
||||||
|
|
||||||
access_token = self._config_entry.data["token"]["access_token"]
|
access_token = self._config_entry.data["token"]["access_token"]
|
||||||
response = requests.request(
|
response = requests.request(
|
||||||
@ -648,7 +648,11 @@ class DataManager:
|
|||||||
try:
|
try:
|
||||||
return await func()
|
return await func()
|
||||||
except Exception as exception1: # pylint: disable=broad-except
|
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
|
exception = exception1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user