Browse Source

Catch Exception rather than BaseException.

System Exceptions like SystemExit and KeyboardInterrupt should always be
passed on, so avoid catching them.  Exception is the base class for all
exceptions that can be handled without rethrowing.
Jason Rumney 3 years ago
parent
commit
cc6d5d6be1
1 changed files with 2 additions and 2 deletions
  1. 2 2
      custom_components/tuya_local/device.py

+ 2 - 2
custom_components/tuya_local/device.py

@@ -158,7 +158,7 @@ class TuyaLocalDevice(object):
                     _LOGGER.debug(f"{self.name} received non data {poll}")
                     _LOGGER.debug(f"{self.name} received non data {poll}")
             _LOGGER.warning(f"{self.name} receive loop has terminated")
             _LOGGER.warning(f"{self.name} receive loop has terminated")
 
 
-        except BaseException as t:
+        except Exception as t:
             _LOGGER.exception(
             _LOGGER.exception(
                 f"{self.name} receive loop terminated by exception {t}",
                 f"{self.name} receive loop terminated by exception {t}",
             )
             )
@@ -205,7 +205,7 @@ class TuyaLocalDevice(object):
                 # Close the persistent connection when exiting the loop
                 # Close the persistent connection when exiting the loop
                 self._api.set_socketPersistent(False)
                 self._api.set_socketPersistent(False)
                 raise
                 raise
-            except BaseException as t:
+            except Exception as t:
                 _LOGGER.exception(
                 _LOGGER.exception(
                     f"{self.name} receive loop error {type(t)}:{t}",
                     f"{self.name} receive loop error {type(t)}:{t}",
                 )
                 )