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: ee43f87cfe88a8155566b662750d663c1d8742ff
Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@clyso.com>
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)