diff --git a/custom_components/xiaomi_home/miot/miot_cloud.py b/custom_components/xiaomi_home/miot/miot_cloud.py index 7e97577..a7ce83e 100644 --- a/custom_components/xiaomi_home/miot/miot_cloud.py +++ b/custom_components/xiaomi_home/miot/miot_cloud.py @@ -97,7 +97,7 @@ def __init__( self._session = aiohttp.ClientSession() def __del__(self): - self._session.close() + self._main_loop.create_task(self._session.close()) def set_redirect_url(self, redirect_url: str) -> None: if not isinstance(redirect_url, str) or redirect_url.strip() == '': @@ -253,7 +253,7 @@ def __init__( self._session = aiohttp.ClientSession() def __del__(self): - self._session.close() + self._main_loop.create_task(self._session.close()) def update_http_header( self, cloud_server: Optional[str] = None,