From 5ebb33d141dc5582e7517257b11afaf69aa824d5 Mon Sep 17 00:00:00 2001 From: Jim Bennett Date: Fri, 17 Apr 2020 14:59:10 -0700 Subject: [PATCH 1/2] Fix for #28 --- adafruit_minimqtt.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/adafruit_minimqtt.py b/adafruit_minimqtt.py index e0f9c3c..9f83f30 100644 --- a/adafruit_minimqtt.py +++ b/adafruit_minimqtt.py @@ -614,8 +614,9 @@ def reconnect(self, resub_topics=True): self.logger.debug( "Attempting to resubscribe to previously subscribed topics." ) - while self._subscribed_topics: - feed = self._subscribed_topics.pop() + subscribed_topics = self._subscribed_topics.copy() + while subscribed_topics: + feed = subscribed_topics.pop() self.subscribe(feed) def loop_forever(self): From dbb1b93644e5ba7ffcc93392cd98975cc6dbacfe Mon Sep 17 00:00:00 2001 From: Jim Bennett Date: Fri, 17 Apr 2020 15:03:49 -0700 Subject: [PATCH 2/2] Resetting subscribed topics list before resubscribing --- adafruit_minimqtt.py | 1 + 1 file changed, 1 insertion(+) diff --git a/adafruit_minimqtt.py b/adafruit_minimqtt.py index 9f83f30..339c009 100644 --- a/adafruit_minimqtt.py +++ b/adafruit_minimqtt.py @@ -615,6 +615,7 @@ def reconnect(self, resub_topics=True): "Attempting to resubscribe to previously subscribed topics." ) subscribed_topics = self._subscribed_topics.copy() + self._subscribed_topics = [] while subscribed_topics: feed = subscribed_topics.pop() self.subscribe(feed)