mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Use call_soon_threadsafe in token updater of Ring (#106984)
Use call_soon_threadsafe in token update of Ring
This commit is contained in:
parent
4f213f6df3
commit
0183affc7c
@ -4,7 +4,6 @@ from __future__ import annotations
|
||||
import asyncio
|
||||
from collections.abc import Callable
|
||||
from datetime import timedelta
|
||||
from functools import partial
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
@ -16,7 +15,6 @@ from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.event import async_track_time_interval
|
||||
from homeassistant.util.async_ import run_callback_threadsafe
|
||||
|
||||
from .const import (
|
||||
DEVICES_SCAN_INTERVAL,
|
||||
@ -41,14 +39,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
||||
def token_updater(token):
|
||||
"""Handle from sync context when token is updated."""
|
||||
run_callback_threadsafe(
|
||||
hass.loop,
|
||||
partial(
|
||||
hass.loop.call_soon_threadsafe(
|
||||
hass.config_entries.async_update_entry,
|
||||
entry,
|
||||
data={**entry.data, CONF_TOKEN: token},
|
||||
),
|
||||
).result()
|
||||
)
|
||||
|
||||
auth = ring_doorbell.Auth(
|
||||
f"{APPLICATION_NAME}/{__version__}", entry.data[CONF_TOKEN], token_updater
|
||||
|
Loading…
x
Reference in New Issue
Block a user