Sha256: 2a0ced3fff3dd0476d20ead2e3e901fee7f7ca3aa5e9769bea6dde9aa8495fe1
Contents?: true
Size: 565 Bytes
Versions: 2
Compression:
Stored size: 565 Bytes
Contents
require "patiently_try/version" module PatientlyTry def patiently_try(opts = {}) retries = opts[:retries] || 100 wait = opts[:wait] || 0 catch_errors = opts[:catch] || StandardError logging = opts[:logging].nil? ? true : opts[:logging] try = 0 begin yield rescue *(Array(catch_errors)) => e try += 1 puts "Failed with: #{e.inspect}" if logging raise e if try >= retries puts "Retrying (#{try}/#{retries})" sleep wait if wait && wait > 0 retry end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
patiently_try-0.1.1 | lib/patiently_try.rb |
patiently_try-0.1.0 | lib/patiently_try.rb |