lib/rbbt/util/misc/development.rb in rbbt-util-5.21.101 vs lib/rbbt/util/misc/development.rb in rbbt-util-5.21.102

- old
+ new

@@ -132,17 +132,23 @@ def self.reset_do_once $__did_once = false end - def self.insist(times = 3, sleep = nil, msg = nil) + 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 + + if sleep.nil? + sleep_array = ([0] + [0.001, 0.01, 0.1] * (times / 3)).sort[0..times-1] + sleep = sleep_array.shift + end + begin yield rescue TryAgain sleep sleep retry @@ -164,10 +170,10 @@ Log.warn("Insisting after exception: #{$!.class} #{$!.message}") end if sleep and try > 0 sleep sleep - sleep = sleep_array.shift if sleep_array + sleep = sleep_array.shift || sleep if sleep_array else Thread.pass end try += 1