Я использую библиотеку paho-mqtt для запуска mqtt-клиента на основе Python.Я не могу опубликовать сообщение из отдельной ветки согласно следующему коду
cb_client = mqtt.Client(
client_id = "timerScript",
userdata = [db,conf],
clean_session = True,
protocol=mqtt.MQTTv311
)
cb_client.username_pw_set(bc['username'], bc['password'])
userdata = [db,conf]
cb_client.connect(host=bc['host'], port=int(bc['port']))
handle_trigger(cb_client, userdata,trigger)
cb_client.loop_forever()
def handle_trigger(cbClient,userdata,trigger):
route = route[0][0]
cbClient.publish("test","from handler") << this is working
t = threading.Thread(target=execute_trigger, args=[cbClient, userdata, trigger,route])
t.daemon = True
t.start()
return
def execute_trigger(cbClient,userdata,trigger,route):
print("Executing trigger {}".format(trigger))
cbClient.publish("test","from thread") # <<this publish in thread is not working