mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix sense doing blocking I/O in the event loop (#123247)
This commit is contained in:
parent
f94bf51bb5
commit
fe4e6f24f5
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from functools import partial
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
@ -80,8 +81,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: SenseConfigEntry) -> boo
|
|||||||
|
|
||||||
client_session = async_get_clientsession(hass)
|
client_session = async_get_clientsession(hass)
|
||||||
|
|
||||||
gateway = ASyncSenseable(
|
# Creating the AsyncSenseable object loads
|
||||||
api_timeout=timeout, wss_timeout=timeout, client_session=client_session
|
# ssl certificates which does blocking IO
|
||||||
|
gateway = await hass.async_add_executor_job(
|
||||||
|
partial(
|
||||||
|
ASyncSenseable,
|
||||||
|
api_timeout=timeout,
|
||||||
|
wss_timeout=timeout,
|
||||||
|
client_session=client_session,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
gateway.rate_limit = ACTIVE_UPDATE_RATE
|
gateway.rate_limit = ACTIVE_UPDATE_RATE
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""Config flow for Sense integration."""
|
"""Config flow for Sense integration."""
|
||||||
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
|
from functools import partial
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
@ -48,8 +49,15 @@ class SenseConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
timeout = self._auth_data[CONF_TIMEOUT]
|
timeout = self._auth_data[CONF_TIMEOUT]
|
||||||
client_session = async_get_clientsession(self.hass)
|
client_session = async_get_clientsession(self.hass)
|
||||||
|
|
||||||
self._gateway = ASyncSenseable(
|
# Creating the AsyncSenseable object loads
|
||||||
api_timeout=timeout, wss_timeout=timeout, client_session=client_session
|
# ssl certificates which does blocking IO
|
||||||
|
self._gateway = await self.hass.async_add_executor_job(
|
||||||
|
partial(
|
||||||
|
ASyncSenseable,
|
||||||
|
api_timeout=timeout,
|
||||||
|
wss_timeout=timeout,
|
||||||
|
client_session=client_session,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
self._gateway.rate_limit = ACTIVE_UPDATE_RATE
|
self._gateway.rate_limit = ACTIVE_UPDATE_RATE
|
||||||
await self._gateway.authenticate(
|
await self._gateway.authenticate(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user