eclipse / paho.mqtt.python

paho.mqtt.python
Other
2.19k stars 723 forks source link

Publishing Message fails if Program exits directly after #741

Closed JannikWilhelm closed 9 months ago

JannikWilhelm commented 1 year ago

Calling client.publish(topic, payload, qos=0) results in the message being handled as sent (client.on_publish function is executed) But if the python script ends after the publish call, the message does not get sent. Adding a time.sleep(1) after client.publish(...) consistently sends the message.

MattBrittan commented 9 months ago

If you want to publish a message and ensure it's left the client before exiting then use single. The library queues publish requests so 'Publish` is likely to return before the message is actually sent.

Closing this for now - if you still have an issue then feel free to reopen but please provide a full example.