Skip to content

Commit

Permalink
Merge pull request sidekiq#2360 from victor-huang/fix_stats_reporting…
Browse files Browse the repository at this point in the history
…_with_redis_sentinel

exponential sleep and increase retries for retry_and_suppress_exceptions
  • Loading branch information
mperham committed May 20, 2015
2 parents a3c5321 + 3adf949 commit a6270c6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/sidekiq/processor.rb
Expand Up @@ -132,20 +132,24 @@ def cloned(ary)

# 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.
def retry_and_suppress_exceptions(max_retries = 2)
def retry_and_suppress_exceptions(max_retries = 5)
retry_count = 0
begin
yield
rescue => e
retry_count += 1
if retry_count <= max_retries
Sidekiq.logger.debug {"Suppressing and retrying error: #{e.inspect}"}
sleep(1)
sleep_retry_count(retry_count)
retry
else
handle_exception(e, { :message => "Exhausted #{max_retries} retries"})
end
end
end

def sleep_retry_count(retry_count)
sleep(retry_count)
end
end
end

0 comments on commit a6270c6

Please sign in to comment.