Skip to content

Commit

Permalink
Merge pull request #57 from want-eat-meat/master
Browse files Browse the repository at this point in the history
fix(tb_device_mqtt):fix high usage of CPU on start
  • Loading branch information
imbeacon authored May 2, 2024
2 parents 9197e75 + 2a7a57b commit 9bab19a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tb_device_mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ def __sending_thread_main(self):
while not self.stopped:
try:
if not self.is_connected():
sleep(.1)
continue
if (not self.__rate_limit.check_limit_reached()
and (self.__rate_limit.get_minimal_limit() == 0
Expand All @@ -681,6 +682,8 @@ def __sending_thread_main(self):
result = self._client.subscribe(item["topic"], qos=item["qos"])
self.__responses[item['id']] = {"info": result, "timeout_ts": int(time()) + DEFAULT_TIMEOUT}
self.__rate_limit.add_counter()
else:
sleep(.1)
else:
sleep(0.1)
except Exception as e:
Expand Down

0 comments on commit 9bab19a

Please sign in to comment.