Skip to content

Commit

Permalink
Run listen_topic in a thread
Browse files Browse the repository at this point in the history
  • Loading branch information
niemijoe committed Sep 5, 2022
1 parent 514fd09 commit 9ccd65e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mqtt_data_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ def main():
for topic in topic_list:
if topic.is_running == False:
print(f"Topic {topic.topic_name} was not running, starting it.")
topic.listen_topic()

# Run listen_topic in a thread because we don't want to wait e.g. client.connect() etc.
# If we didn't use threads here, one connection being stuck could cause long
# timeout for sending data to Azure.
t = Thread(target=topic.listen_topic)
t.start()

sleep_time = time_end - time.time()
print(sleep_time)
Expand Down

0 comments on commit 9ccd65e

Please sign in to comment.