wait_for_publish() deadlocks with qos=2 on server or connection shutdown
I am using loop_start() and publish messages with qos level 2 and then wait for the message to be properly published via wait_for_publish(). Stopping the mqtt server sometimes results in a race condition where wait_for_publish() will lock up infinitely, probably waiting for the qos handshake to finish, but the connection is already dead. This completely deadlocks the thread. The automatic reconnect of loop_start() does not resolve this either, even if the server restarts.
topic = "test"
payload = "test"
publish_status = client.publish(topic, payload, qos=2)
# This will sometimes deadlock when shutting down the server externally or dropping connection
publish_status.wait_for_publish()
I inspect the same behaviour with qos=1 and a Mosquitto broker.
The Mosquitto server timeouts the client, but the python program is still running.
Apologies for the delay in someone looking into this.
I'd appreciate it if someone could confirm if this is still an issue with the current release and provide a reproducer and/or logs (understand that this might be difficult to reproduce). In theory the client should reconnect, and the publish process should conclude as normal (but this gets complicated and I have not traced in detail).