eclipse / paho.mqtt.python

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

Paho.mqtt.publish.multiple hangs if given an empty list of messages #684

Closed semicolonTransistor closed 1 year ago

semicolonTransistor commented 1 year ago

Assuming an MQTT broker is set up on localhost at port 1883, running the following snipping will hang.

publish.multiple(
        msgs=[],
    )

I have not been quite able to pinpoint why this happens, it seems likely due to _on_publish never being called, and the client is never disconnected.

If this is unintentional, I'd suggest adding an else clause to the check for len(userdata) > 0 in _on_connect and disconnecting the client there.

If this is indeed the intended behavior, could the documentation be made clearer on it?

Thanks!

ralight commented 1 year ago

Thank you, this case will now raise a ValueError - it shouldn't be allowed. It will be in the next release.