fix: cancel old thread

This commit is contained in:
Florian Bezannier
2025-09-30 12:54:02 +02:00
parent b658859c67
commit 5c5ec570ab
@@ -71,7 +71,7 @@ class PSAClient:
self.set_proxies(proxies)
self.config_file = DEFAULT_CONFIG_FILENAME
Ecomix.co2_signal_key = co2_signal_api
self.refresh_thread = None
self.refresh_thread: threading.Timer = None
remote_credentials = RemoteCredentials(remote_refresh_token)
remote_credentials.update_callbacks.append(self.save_config)
self.remote_client = RemoteClient(self.account_info,
@@ -119,6 +119,7 @@ class PSAClient:
if self.info_refresh_rate is not None:
if self.refresh_thread and self.refresh_thread.is_alive():
logger.debug("refresh_vehicle_info: precedent task still alive")
self.refresh_thread.cancel()
self.refresh_thread = threading.Timer(self.info_refresh_rate, self.__refresh_vehicle_info)
self.refresh_thread.daemon = True
self.refresh_thread.start()