paho.mqtt.python
paho.mqtt.python copied to clipboard
Make use of loop_stop()'s force parameter
Currently (v1.5.1), the force
parameter in loop_stop
does nothing. I ran into an issue where a packet with QoS 2 was sent by the client and does not respond - effectively locking up the client waiting for a response. I am calling Client.loop_stop()
to forcefully exit, but loop_stop stalls.
Client.loop_stop()
(client.py):
def loop_stop(self, force=False):
"""This is part of the threaded client interface. Call this once to
stop the network thread previously created with loop_start(). This call
will block until the network thread finishes.
The force parameter is currently ignored.
"""
Quick fix for my use-case:
Set the timeout
for the join()
call to 30 seconds:
if self.threading.current_thread() != self._thread:
#self._thread.join()
self._thread.join(timeout=30.0 if force else None)
self._thread = None
Just noting that this is still the case with @master (it's documented "The force parameter is currently ignored."). I'll flag this as an enhancement.