1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

created a method for sleep with retry count for monkey patching

This commit is contained in:
Victor Huang 2015-05-19 15:05:09 -07:00
parent c47bcf8a61
commit 580cf0d520

View file

@ -132,7 +132,7 @@ module Sidekiq
# If an exception occurs in the block passed to this method, that block will be retried up to max_retries times. # If an exception occurs in the block passed to this method, that block will be retried up to max_retries times.
# All exceptions will be swallowed and logged. # All exceptions will be swallowed and logged.
def retry_and_suppress_exceptions(max_retries = 5) def retry_and_suppress_exceptions(max_retries = 2)
retry_count = 0 retry_count = 0
begin begin
yield yield
@ -140,12 +140,16 @@ module Sidekiq
retry_count += 1 retry_count += 1
if retry_count <= max_retries if retry_count <= max_retries
Sidekiq.logger.debug {"Suppressing and retrying error: #{e.inspect}"} Sidekiq.logger.debug {"Suppressing and retrying error: #{e.inspect}"}
sleep(retry_count * retry_count) sleep_retry_count(retry_count)
retry retry
else else
handle_exception(e, { :message => "Exhausted #{max_retries} retries"}) handle_exception(e, { :message => "Exhausted #{max_retries} retries"})
end end
end end
end end
def sleep_retry_count(retry_count)
sleep(retry_count)
end
end end
end end