Skip to content

Commit

Permalink
Merge pull request #809 from jiachin1995/master
Browse files Browse the repository at this point in the history
Fix loop_stop() not clearing ._thread when called from same thread
  • Loading branch information
PierreF authored Mar 27, 2024
2 parents f544b4e + 7a0d184 commit 28aa2e6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/paho/mqtt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2356,7 +2356,6 @@ def loop_stop(self) -> MQTTErrorCode:
self._thread_terminate = True
if threading.current_thread() != self._thread:
self._thread.join()
self._thread = None

return MQTTErrorCode.MQTT_ERR_SUCCESS

Expand Down Expand Up @@ -4514,7 +4513,10 @@ def _handle_on_connect_fail(self) -> None:
MQTT_LOG_ERR, 'Caught exception in on_connect_fail: %s', err)

def _thread_main(self) -> None:
self.loop_forever(retry_first_connection=True)
try:
self.loop_forever(retry_first_connection=True)
finally:
self._thread = None

def _reconnect_wait(self) -> None:
# See reconnect_delay_set for details
Expand Down

0 comments on commit 28aa2e6

Please sign in to comment.