Skip to content

Commit

Permalink
Merge pull request #622 from jurijsteblaj/fix/wait-time-func
Browse files Browse the repository at this point in the history
Use time_func for timeout in wait_for_publish
  • Loading branch information
PierreF authored Dec 22, 2023
2 parents 3123149 + 1ace8d9 commit 832c313
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/paho/mqtt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,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():
Expand Down

0 comments on commit 832c313

Please sign in to comment.