From 7b0950fca948f421f66001129e92ce0918533509 Mon Sep 17 00:00:00 2001 From: Lurker00 Date: Mon, 29 Jul 2024 16:20:09 +0300 Subject: [PATCH] Fix: not all the places catch exceptions from exchange() --- custom_components/localtuya/core/pytuya/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/custom_components/localtuya/core/pytuya/__init__.py b/custom_components/localtuya/core/pytuya/__init__.py index af4394c43..c154aaec2 100644 --- a/custom_components/localtuya/core/pytuya/__init__.py +++ b/custom_components/localtuya/core/pytuya/__init__.py @@ -1086,7 +1086,10 @@ async def exchange(self, command, dps=None, nodeID=None, payload=None): enc_payload = self._encode_message(payload) - await self.transport_write(enc_payload) + try: + await self.transport_write(enc_payload) + except Exception: # pylint: disable=broad-except + return self.clean_up_session() msg = await self.dispatcher.wait_for(seqno, payload.cmd) if msg is None: self.debug("Wait was aborted for seqno %d", seqno)