Skip to content

Commit

Permalink
contextutil: sleep between tries in safe_while again
Browse files Browse the repository at this point in the history
This patch fixes an issue introduced within PR #1816,
that when tries are < 0 (e.g. -1) there is no sleep
occurred between tries.

It also fixes error message, so we repot correct
number of tries we've done now.

Fixes: ee43f87

Signed-off-by: Kyr Shatskyy <[email protected]>
  • Loading branch information
Kyr Shatskyy committed Aug 6, 2024
1 parent cf24c2c commit 7f1968c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions teuthology/contextutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,20 @@ def _make_error_msg(self):

msg = msg.format(
action=self.action,
tries=self.counter,
tries=self.counter - 1,
total=self.total_seconds,
)
return msg

def __call__(self):
if self.tries < 0:
return True
self.counter += 1
if self.counter == 1:
return True
def must_stop():
return self.tries > 0 and self.counter > self.tries
if ((self.timeout > 0 and
self.total_seconds >= self.timeout) or
(self.timeout == 0 and self.counter > self.tries)):
(self.timeout == 0 and must_stop())):
error_msg = self._make_error_msg()
if self._raise:
raise MaxWhileTries(error_msg)
Expand Down

0 comments on commit 7f1968c

Please sign in to comment.