mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Fix blocking call in Tuya initialisation (#157477)
This commit is contained in:
@@ -44,10 +44,9 @@ class HomeAssistantTuyaData(NamedTuple):
|
||||
listener: SharingDeviceListener
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: TuyaConfigEntry) -> bool:
|
||||
"""Async setup hass config entry."""
|
||||
token_listener = TokenListener(hass, entry)
|
||||
manager = Manager(
|
||||
def _create_manager(entry: TuyaConfigEntry, token_listener: TokenListener) -> Manager:
|
||||
"""Create a Tuya Manager instance."""
|
||||
return Manager(
|
||||
TUYA_CLIENT_ID,
|
||||
entry.data[CONF_USER_CODE],
|
||||
entry.data[CONF_TERMINAL_ID],
|
||||
@@ -56,6 +55,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: TuyaConfigEntry) -> bool
|
||||
token_listener,
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: TuyaConfigEntry) -> bool:
|
||||
"""Async setup hass config entry."""
|
||||
token_listener = TokenListener(hass, entry)
|
||||
|
||||
# Move to executor as it makes blocking call to import_module
|
||||
# with args ('.system', 'urllib3.contrib.resolver')
|
||||
manager = await hass.async_add_executor_job(_create_manager, entry, token_listener)
|
||||
|
||||
listener = DeviceListener(hass, manager)
|
||||
manager.add_device_listener(listener)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user