From 1ace8d9abbe2a4e6d36f58306e8f0dac1ce35173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jurij=20=C5=A0teblaj?= Date: Thu, 18 Nov 2021 17:55:46 +0100 Subject: [PATCH] Use time_func for timeout in wait_for_publish MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jurij Šteblaj --- src/paho/mqtt/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/paho/mqtt/client.py b/src/paho/mqtt/client.py index 1c0236e4..d3629091 100644 --- a/src/paho/mqtt/client.py +++ b/src/paho/mqtt/client.py @@ -361,10 +361,10 @@ def wait_for_publish(self, timeout=None): elif self.rc > 0: raise RuntimeError('Message publish failed: %s' % (error_string(self.rc))) - timeout_time = None if timeout is None else time.time() + timeout + timeout_time = None if timeout is None else time_func() + timeout timeout_tenth = None if timeout is None else timeout / 10. def timed_out(): - return False if timeout is None else time.time() > timeout_time + return False if timeout is None else time_func() > timeout_time with self._condition: while not self._published and not timed_out():