Skip to content

Commit

Permalink
Specifically catch RequestException instead of all
Browse files Browse the repository at this point in the history
  • Loading branch information
ZephireNZ committed Feb 6, 2022
1 parent 78d4a7b commit 601b35d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tuya_iot/openmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from Crypto.Cipher import AES
from paho.mqtt import client as mqtt
from requests.exceptions import RequestException

from .openapi import TO_C_SMART_HOME_REFRESH_TOKEN_API, TuyaOpenAPI
from .openlogging import logger
Expand Down Expand Up @@ -162,7 +163,8 @@ def run(self):

# reconnect every 2 hours required.
time.sleep(self.mq_config.expire_time - 60)
except:
except RequestException as e:
logger.exception(e)
logger.error(f"failed to refresh mqtt server, retrying in {backoff_seconds} seconds.")

time.sleep(backoff_seconds)
Expand Down

0 comments on commit 601b35d

Please sign in to comment.