lib/rbbt/util/misc/development.rb in rbbt-util-5.34.5 vs lib/rbbt/util/misc/development.rb in rbbt-util-5.34.7

- old
+ new

@@ -133,23 +133,28 @@ def self.reset_do_once $__did_once = false end def self.insist(times = 4, sleep = nil, msg = nil) - if Array === times - sleep_array = times - times = sleep_array.length - sleep = sleep_array.shift - end - try = 0 + sleep_array = nil - if sleep.nil? - sleep_array = ([0] + [0.001, 0.01, 0.1, 0.5] * (times / 3)).sort[0..times-1] - sleep = sleep_array.shift - end - + try = 0 begin - yield + begin + yield + rescue Exception + if Array === times + sleep_array = times + times = sleep_array.length + sleep = sleep_array.shift + end + + if sleep.nil? + sleep_array = ([0] + [0.001, 0.01, 0.1, 0.5] * (times / 3)).sort[0..times-1] + sleep = sleep_array.shift + end + raise $! + end rescue TryAgain sleep sleep retry rescue StopInsist raise $!.exception