I have some code that sets up MQTT and runs loop_forever() in order to start the MQTT loop.
Now, I want to terminate that call from a callback like on_publish. As such, I have two questions:
- Is there a better pattern to just publish a message and exit than running
loop_forever? I would like to avoid starting another thread using loop_start
- Currently, I am doing
connection._thread_terminate = True, which is a hack, really. Is there a better way to stop the loop?
Thanks a lot!
I have some code that sets up MQTT and runs
loop_forever()in order to start the MQTT loop.Now, I want to terminate that call from a callback like
on_publish. As such, I have two questions:loop_forever? I would like to avoid starting another thread usingloop_startconnection._thread_terminate = True, which is a hack, really. Is there a better way to stop the loop?Thanks a lot!