Method: Cnvrg::Helpers#try_until_success
- Defined in:
- lib/cnvrg/helpers.rb
#try_until_success(tries: 3) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cnvrg/helpers.rb', line 30 def try_until_success(tries: 3) exception = nil tries.times do |i| begin yield return true rescue => e Cnvrg::Logger.log_info("Error while trying for the #{i} time") Cnvrg::Logger.log_error(e) sleep(1) exception = e end end raise exception end |