From 4679a8bae834ab24c1cbc18e75b6b6ab6af4d18d Mon Sep 17 00:00:00 2001 From: sworld Date: Sat, 21 Dec 2024 23:36:15 +0800 Subject: [PATCH] fix: wrong use of session close --- custom_components/xiaomi_home/miot/miot_cloud.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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,