Skip to content

Commit

Permalink
Fix crash on reconnect check. Fixes #18.
Browse files Browse the repository at this point in the history
  • Loading branch information
slvwolf committed Jun 18, 2023
1 parent b26047e commit 0b4cef2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pcfmqtt/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def start(self):
try:
while True:
if not self._check_and_reconnect():
self._log.warn("Connection errors. Waiting for 10 minutes: %r", e)
self._log.warn("Connection errors. Waiting for 10 minutes")
time.sleep(600)
continue
try:
Expand Down Expand Up @@ -135,8 +135,10 @@ def start(self):
self._log.exception("Interrupted", e)
finally:
self._log.info("Shutting down")
self._client.disconnect()
self._session.logout()
if self._client is not None:
self._client.disconnect()
if self._session is not None:
self._session.logout()

def on_connect(self, client: mqtt.Client, userdata, flags, rc):
self._log.info("Connected")
Expand Down

0 comments on commit 0b4cef2

Please sign in to comment.